Skip to content

Commit 0f43fed

Browse files
dhhandrewn617tutefedesapuppozzak
authored
No new apps should be started with sprockets (rails#52887)
* No new apps should be started with sprockets Co-authored-by: Andrew Novoselac <[email protected]> Co-authored-by: Tute Costa <[email protected]> Co-authored-by: Federico Sapuppo <[email protected]> Co-authored-by: zzak <[email protected]> Co-authored-by: Federico Sapuppo <[email protected]>
1 parent cefd95b commit 0f43fed

File tree

22 files changed

+748
-416
lines changed

22 files changed

+748
-416
lines changed

railties/lib/rails/commands/app/update_command.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,13 @@ def generator_options
7373
skip_rubocop: skip_gem?("rubocop"),
7474
skip_test: !defined?(Rails::TestUnitRailtie),
7575
skip_system_test: Rails.application.config.generators.system_tests.nil?,
76-
asset_pipeline: asset_pipeline,
7776
skip_asset_pipeline: asset_pipeline.nil?,
7877
skip_bootsnap: !defined?(Bootsnap),
7978
}.merge(options)
8079
end
8180

8281
def asset_pipeline
83-
case
84-
when defined?(Sprockets::Railtie)
85-
"sprockets"
86-
when defined?(Propshaft::Railtie)
87-
"propshaft"
88-
else
89-
nil
90-
end
82+
"propshaft" if defined?(Propshaft::Railtie)
9183
end
9284

9385
def skip_gem?(gem_name)

railties/lib/rails/generators/app_base.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class AppBase < Base # :nodoc:
1919

2020
JAVASCRIPT_OPTIONS = %w( importmap bun webpack esbuild rollup )
2121
CSS_OPTIONS = %w( tailwind bootstrap bulma postcss sass )
22-
ASSET_PIPELINE_OPTIONS = %w( none sprockets propshaft )
2322

2423
attr_accessor :rails_template
2524
add_shebang_option!
@@ -74,10 +73,6 @@ def self.add_shared_options_for(name)
7473

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

77-
class_option :asset_pipeline, type: :string, aliases: "-a", default: "propshaft",
78-
enum: ASSET_PIPELINE_OPTIONS,
79-
desc: "Choose your asset pipeline"
80-
8176
class_option :skip_javascript, type: :boolean, aliases: ["-J", "--skip-js"], default: (true if name == "plugin"),
8277
desc: "Skip JavaScript files"
8378

@@ -296,12 +291,7 @@ def web_server_gemfile_entry # :doc:
296291
end
297292

298293
def asset_pipeline_gemfile_entry
299-
return if skip_asset_pipeline?
300-
301-
if options[:asset_pipeline] == "sprockets"
302-
GemfileEntry.floats "sprockets-rails",
303-
"The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]"
304-
elsif options[:asset_pipeline] == "propshaft"
294+
unless skip_asset_pipeline?
305295
GemfileEntry.floats "propshaft", "The modern asset pipeline for Rails [https://github.com/rails/propshaft]"
306296
end
307297
end
@@ -395,14 +385,6 @@ def skip_asset_pipeline? # :doc:
395385
options[:skip_asset_pipeline]
396386
end
397387

398-
def skip_sprockets?
399-
skip_asset_pipeline? || options[:asset_pipeline] != "sprockets"
400-
end
401-
402-
def skip_propshaft?
403-
skip_asset_pipeline? || options[:asset_pipeline] != "propshaft"
404-
end
405-
406388
def skip_thruster?
407389
options[:skip_thruster]
408390
end

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def config_when_updating
142142
active_storage_config_exist = File.exist?("config/storage.yml")
143143
rack_cors_config_exist = File.exist?("config/initializers/cors.rb")
144144
assets_config_exist = File.exist?("config/initializers/assets.rb")
145-
asset_manifest_exist = File.exist?("app/assets/config/manifest.js")
146145
asset_app_stylesheet_exist = File.exist?("app/assets/stylesheets/application.css")
147146
csp_config_exist = File.exist?("config/initializers/content_security_policy.rb")
148147

@@ -158,15 +157,11 @@ def config_when_updating
158157
template "config/storage.yml"
159158
end
160159

161-
if skip_sprockets? && skip_propshaft? && !assets_config_exist
160+
if skip_asset_pipeline? && !assets_config_exist
162161
remove_file "config/initializers/assets.rb"
163162
end
164163

165-
if skip_sprockets? && !asset_manifest_exist
166-
remove_file "app/assets/config/manifest.js"
167-
end
168-
169-
if skip_sprockets? && !asset_app_stylesheet_exist
164+
if skip_asset_pipeline? && !asset_app_stylesheet_exist
170165
remove_file "app/assets/stylesheets/application.css"
171166
end
172167

@@ -506,14 +501,9 @@ def delete_public_files_if_api_option
506501
end
507502
end
508503

509-
def delete_assets_initializer_skipping_sprockets_and_propshaft
510-
if skip_sprockets? && skip_propshaft?
504+
def delete_assets_initializer_skipping_asset_pipeline
505+
if skip_asset_pipeline?
511506
remove_file "config/initializers/assets.rb"
512-
end
513-
514-
if skip_sprockets?
515-
remove_file "app/assets/config/manifest.js"
516-
remove_dir "app/assets/config"
517507
remove_file "app/assets/stylesheets/application.css"
518508
create_file "app/assets/stylesheets/application.css", "/* Application styles */\n" unless options[:api]
519509
end

railties/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt

Lines changed: 0 additions & 2 deletions
This file was deleted.

railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<link rel="icon" href="/icon.png" type="image/png">
1515
<link rel="icon" href="/icon.svg" type="image/svg+xml">
1616
<link rel="apple-touch-icon" href="/icon.png">
17-
<% style_link_target = options[:asset_pipeline] == "propshaft" ? ":all" : "\"application\"" %>
17+
<% style_link_target = options[:skip_asset_pipeline] ? "\"application\"" : ":all" %>
1818
<%- if options[:skip_hotwire] || options[:skip_javascript] -%>
1919
<%%= stylesheet_link_tag <%= style_link_target %> %>
2020
<%- else -%>

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ Rails.application.configure do
6767
# Highlight code that enqueued background job in logs.
6868
config.active_job.verbose_enqueue_logs = true
6969

70-
<%- end -%>
71-
<%- unless skip_sprockets? -%>
72-
# Suppress logger output for asset requests.
73-
config.assets.quiet = true
74-
7570
<%- end -%>
7671
# Raises error for missing translations.
7772
# config.i18n.raise_on_missing_translations = true

railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ Rails.application.configure do
2323
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
2424
# config.public_file_server.enabled = false
2525

26-
<%- unless skip_sprockets? -%>
27-
# Compress CSS using a preprocessor.
28-
# config.assets.css_compressor = :sass
29-
30-
# Do not fall back to assets pipeline if a precompiled asset is missed.
31-
config.assets.compile = false
32-
33-
<%- end -%>
3426
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3527
# config.asset_host = "http://assets.example.com"
3628

railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,3 @@ Rails.application.config.assets.version = "1.0"
55

66
# Add additional assets to the asset load path.
77
# Rails.application.config.assets.paths << Emoji.images_path
8-
<% if options[:asset_pipeline] == "sprockets" -%>
9-
10-
# Precompile additional assets.
11-
# application.js, application.css, and all non-JS/CSS in the app/assets
12-
# folder are already added.
13-
# Rails.application.config.assets.precompile += %w[ admin.js admin.css ]
14-
<% end -%>

railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ def test_dummy_config
152152
end
153153
end
154154

155-
def test_dummy_sprocket_assets
156-
template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
157-
template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
155+
def test_dummy_assets
156+
template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
158157
end
159158

160159
def test_dummy_clean
@@ -170,10 +169,6 @@ def test_dummy_clean
170169
end
171170
end
172171

173-
def assets_manifest
174-
template "rails/engine_manifest.js", "app/assets/config/#{underscored_name}_manifest.js"
175-
end
176-
177172
def stylesheets
178173
if mountable?
179174
copy_file "rails/stylesheets.css",
@@ -364,7 +359,7 @@ def create_dummy_app(path = nil)
364359
mute do
365360
build(:generate_test_dummy)
366361
build(:test_dummy_config)
367-
build(:test_dummy_sprocket_assets) unless skip_sprockets?
362+
build(:test_dummy_assets) unless skip_asset_pipeline?
368363
build(:test_dummy_clean)
369364
# ensure that bin/rails has proper dummy_path
370365
build(:bin)

railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js.tt

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)