Install dartsass-rails when generating app with sass (#47545)

This commit is contained in:
Lázaro Nixon 2023-03-01 00:51:29 -05:00 committed by GitHub
parent 05dc09385f
commit bde99e52ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 3 deletions

@ -24,6 +24,7 @@ gem "jsbundling-rails"
gem "cssbundling-rails"
gem "importmap-rails"
gem "tailwindcss-rails"
gem "dartsass-rails"
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid Active Model (and by extension the entire framework)
# being dependent on a binary library.

@ -168,6 +168,8 @@ GEM
railties (>= 6.0.0)
dalli (3.2.3)
dante (0.2.0)
dartsass-rails (0.4.1)
railties (>= 6.0.0)
date (3.3.3)
debug (1.7.1)
irb (>= 1.5.0)
@ -540,6 +542,7 @@ DEPENDENCIES
connection_pool
cssbundling-rails
dalli (>= 3.0.1)
dartsass-rails
debug (>= 1.1.0)
delayed_job
delayed_job_active_record

@ -135,7 +135,7 @@ that you should choose a traditional bundler include:
[tree-shaking](https://webpack.js.org/guides/tree-shaking/).
* If you will install Bootstrap, Bulma, PostCSS, or Dart CSS through the
[cssbundling-rails gem](https://github.com/rails/cssbundling-rails). All options provided by this
gem except Tailwind will automatically install `esbuild` for you if you do not specify a different
gem except Tailwind and Sass will automatically install `esbuild` for you if you do not specify a different
option in `rails new`.
Turbo

@ -546,10 +546,10 @@ def dockerfile_deploy_packages
packages.sort
end
# CSS processors other than Tailwind require a node-based JavaScript environment. So overwrite the normal JS default
# CSS processors other than Tailwind and Sass require a node-based JavaScript environment. So overwrite the normal JS default
# if one such processor has been specified.
def adjusted_javascript_option
if options[:css] && options[:css] != "tailwind" && options[:javascript] == "importmap"
if options[:css] && options[:css] != "tailwind" && options[:css] != "sass" && options[:javascript] == "importmap"
"esbuild"
else
options[:javascript]
@ -561,6 +561,8 @@ def css_gemfile_entry
if !using_node? && options[:css] == "tailwind"
GemfileEntry.floats "tailwindcss-rails", "Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]"
elsif !using_node? && options[:css] == "sass"
GemfileEntry.floats "dartsass-rails", "Use Dart SASS [https://github.com/rails/dartsass-rails]"
else
GemfileEntry.floats "cssbundling-rails", "Bundle and process CSS [https://github.com/rails/cssbundling-rails]"
end
@ -673,6 +675,8 @@ def run_css
if !using_node? && options[:css] == "tailwind"
rails_command "tailwindcss:install"
elsif !using_node? && options[:css] == "sass"
rails_command "dartsass:install"
else
rails_command "css:install:#{options[:css]}"
end

@ -868,6 +868,12 @@ def test_css_option_with_asset_pipeline_tailwind
end
end
def test_css_option_with_asset_pipeline_sass
run_generator_and_bundler [destination_root, "--css=sass"]
assert_gem "dartsass-rails"
assert_file "app/assets/stylesheets/application.scss"
end
def test_css_option_with_cssbundling_gem
run_generator_and_bundler [destination_root, "--css=postcss"]
assert_gem "cssbundling-rails"