Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change asset pipeline default to Propshaft in Rails 8 #51799

Merged
merged 11 commits into from
May 26, 2024
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def self.add_shared_options_for(name)

class_option :skip_asset_pipeline, type: :boolean, aliases: "-A", default: nil

class_option :asset_pipeline, type: :string, aliases: "-a", default: "sprockets",
class_option :asset_pipeline, type: :string, aliases: "-a", default: "propshaft",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be done in a follow-up PR, but are there documentation changes that we'd like to do as well?

enum: ASSET_PIPELINE_OPTIONS,
desc: "Choose your asset pipeline"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<% style_link_target = options[:asset_pipeline] == "propshaft" ? ":all" : "application" %>
dhh marked this conversation as resolved.
Show resolved Hide resolved
<%- if options[:skip_hotwire] || options[:skip_javascript] -%>
<%%= stylesheet_link_tag "application" %>
<%%= stylesheet_link_tag <%= style_link_target %> %>
<%- else -%>
<%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%%= stylesheet_link_tag <%= style_link_target %>, "data-turbo-track": "reload" %>
<%- end -%>
</head>

Expand Down
20 changes: 10 additions & 10 deletions railties/test/generators/plugin_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,12 @@ def test_dummy_application_configures_asset_pipeline_when_mountable
def test_dummy_application_configures_asset_pipeline_when_full
run_generator [destination_root, "--full"]

assert_gem "sprockets-rails"
assert_file "test/dummy/app/assets/config/manifest.js"
assert_gem "propshaft"
assert_no_gem "sprockets-rails"
assert_file "test/dummy/config/initializers/assets.rb"
assert_file "test/dummy/config/environments/development.rb" do |content|
assert_no_match "config.assets", content
end
end

def test_dummy_application_skips_asset_pipeline_when_flag_skip_asset_pipeline
Expand All @@ -678,20 +682,16 @@ def test_dummy_application_skips_asset_pipeline_when_flag_skip_asset_pipeline
end

def test_dummy_application_respects_asset_pipeline_gem_choice
run_generator [destination_root, "--mountable", "--asset-pipeline=propshaft"]
run_generator [destination_root, "--mountable", "--asset-pipeline=sprockets"]

assert_gem "propshaft"
assert_no_gem "sprockets-rails"
assert_file "test/dummy/config/initializers/assets.rb"
assert_file "test/dummy/config/environments/development.rb" do |content|
assert_no_match "config.assets", content
end
assert_gem "sprockets-rails"
assert_file "test/dummy/app/assets/config/manifest.js"
end

def test_no_asset_pipeline_gem_when_no_dummy_application
run_generator [destination_root, "--mountable", "--skip-test"]

assert_no_gem "sprockets-rails"
assert_no_gem "propshaft"
assert_no_directory "test/dummy"
end

Expand Down