sprockets-rails icon indicating copy to clipboard operation
sprockets-rails copied to clipboard

No longer can remove app/assets after compile

Open SampsonCrowley opened this issue 5 years ago • 2 comments

because Sprockets throws an error when "manifest" is missing, it's impossible to compile assets, and then delete the source folder. this is a really bad direction for people who use services like heroku, where speed is dependent on post-compiled app size. I shouldn't need to keep my source files after they've been compiled, just to start my server

SampsonCrowley avatar Jan 06 '20 22:01 SampsonCrowley

If you want to remove the assets folder you need to find and remove any config options that reference assets (example from development.rb: config.assets.quiet = true), and then in application.rb, instead of requiring all of the rails libraries with require "rails/all", replace it with something like the following:

%w(
  active_record/railtie
  active_storage/engine
  action_controller/railtie
  action_view/railtie
  action_mailer/railtie
  active_job/railtie
  action_cable/engine
  action_mailbox/engine
  action_text/engine
  rails/test_unit/railtie
- sprockets/railtie
).each do |railtie|
  begin
    require railtie
  rescue LoadError
  end
end

See https://github.com/rails/rails/blob/master/railties/lib/rails/all.rb as to where I am pulling this. Basically we just no longer want to require sprockets.

Hopefully this made some sense. I have removed app/assets from several projects by doing this.

andrewmcodes avatar May 14 '20 21:05 andrewmcodes

@andrewmcodes the goal isn't to remove sprockets, it's to remove the unneeded source files in production

SampsonCrowley avatar May 15 '20 05:05 SampsonCrowley