diff --git a/minify-html-ruby/lib/minify_html.rb b/minify-html-ruby/lib/minify_html.rb
index fef291d1..bc38370d 100644
--- a/minify-html-ruby/lib/minify_html.rb
+++ b/minify-html-ruby/lib/minify_html.rb
@@ -1 +1,8 @@
-require_relative "minify_html/minify_html"
+# frozen_string_literal: true
+
+begin
+ /(?\d+\.\d+)/ =~ RUBY_VERSION
+ require_relative "#{ruby_version}/minify_html"
+rescue LoadError
+ require_relative "minify_html.so"
+end
diff --git a/minify-html-ruby/minify_html.gemspec b/minify-html-ruby/minify_html.gemspec
index b61dd513..5aa201e0 100644
--- a/minify-html-ruby/minify_html.gemspec
+++ b/minify-html-ruby/minify_html.gemspec
@@ -4,7 +4,8 @@ Gem::Specification.new do |spec|
spec.authors = ["Wilson Lin"]
spec.email = ["code@wilsonl.in"]
spec.license = "MIT"
- spec.files = Dir["lib/**", "ext/**", "README.md"]
+ # Cargo.toml represents workspace created during CI workflow, required for building native extension from source.
+ spec.files = Dir["lib/**", "ext/**", "Cargo.toml", "README.md"]
spec.summary = "Extremely fast and smart HTML + JS + CSS minifier"
spec.homepage = "https://github.com/wilsonzlin/minify-html"