1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

removed sprocket related files manifest.js and application.css from generated rails app when --skip-sprockets flag passed into rails new and app:update

This commit is contained in:
Cindy Gao 2020-11-30 19:28:15 -05:00
parent 89414f561a
commit d620f068c2
5 changed files with 28 additions and 3 deletions

View file

@ -1,3 +1,8 @@
* Removed manifest.js and application.css in app/assets
folder when --skip-sprockets option passed as flag to rails.
*Cindy Gao*
* Add support for stylesheets and ERB views to `rails stats`.
*Joel Hawksley*

View file

@ -137,7 +137,9 @@ module Rails
active_storage_config_exist = File.exist?("config/storage.yml")
rack_cors_config_exist = File.exist?("config/initializers/cors.rb")
assets_config_exist = File.exist?("config/initializers/assets.rb")
csp_config_exist = File.exist?("config/initializers/content_security_policy.rb")
asset_manifest_exist = File.exist?("app/assets/config/manifest.js")
asset_app_stylesheet_exist = File.exist?("app/assets/stylesheets/application.css")
csp_config_exist = File.exist?("config/initializers/content_security_policy.rb")
permissions_policy_config_exist = File.exist?("config/initializers/permissions_policy.rb")
@config_target_version = Rails.application.config.loaded_config_version || "5.0"
@ -161,6 +163,14 @@ module Rails
remove_file "config/initializers/assets.rb"
end
if options[:skip_sprockets] && !asset_manifest_exist
remove_file "app/assets/config/manifest.js"
end
if options[:skip_sprockets] && !asset_app_stylesheet_exist
remove_file "app/assets/stylesheets/application.css"
end
unless rack_cors_config_exist
remove_file "config/initializers/cors.rb"
end
@ -491,6 +501,8 @@ module Rails
def delete_assets_initializer_skipping_sprockets
if options[:skip_sprockets]
remove_file "config/initializers/assets.rb"
remove_file "app/assets/config/manifest.js"
remove_file "app/assets/stylesheets/application.css"
end
end

View file

@ -125,8 +125,11 @@ task default: :test
end
end
def test_dummy_assets
def test_dummy_webpacker_assets
template "rails/javascripts.js", "#{dummy_path}/app/javascript/packs/application.js", force: true
end
def test_dummy_sprocket_assets
template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
end
@ -290,7 +293,8 @@ task default: :test
mute do
build(:generate_test_dummy)
build(:test_dummy_config)
build(:test_dummy_assets)
build(:test_dummy_webpacker_assets)
build(:test_dummy_sprocket_assets) unless options[:skip_sprockets]
build(:test_dummy_clean)
# ensure that bin/rails has proper dummy_path
build(:bin, true)

View file

@ -325,6 +325,8 @@ class AppGeneratorTest < Rails::Generators::TestCase
quietly { generator.update_config_files }
assert_no_file "#{app_root}/config/initializers/assets.rb"
assert_no_file "#{app_root}/app/assets/config/manifest.js"
assert_no_file "#{app_root}/app/assets/stylesheets/application.css"
end
end

View file

@ -320,6 +320,8 @@ module SharedGeneratorTests
run_generator [destination_root, "--skip-sprockets"]
assert_no_file "#{application_path}/config/initializers/assets.rb"
assert_no_file "#{application_path}/app/assets/config/manifest.js"
assert_no_file "#{application_path}/app/assets/stylesheets/application.css"
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']sprockets\/railtie["']/