Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails skip initializer on asset precompile

I'd like to skip one of my initializer files during asset precompilation. Is this possible in Rails 4? Seems like initialize_on_precompile was removed.

thanks

like image 359
montrealmike Avatar asked Dec 16 '14 05:12

montrealmike


People also ask

How do you Precompile Rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What is assets Precompile?

rails assets:precompile is the task that does the compilation (concatenation, minification, and preprocessing). When the task is run, Rails first looks at the files in the config.assets.precompile array. By default, this array includes application.js and application.css .

What does rake assets Clean do?

Two cleanup tasks: rake assets:clean is now a safe cleanup that only removes older assets that are no longer used, while rake assets:clobber nukes the entire public/assets directory. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.


1 Answers

There seems to be no way to do this in a rails way. We have done something like below

if ENV['ASSET_PRECOMPILE'].blank?
  Airbrake.configure do |config|
    config.project_id = ENV['AIRBRAKE_PROJECT_ID']
    config.project_key = ENV['AIRBRAKE_PROJECT_KEY']
    config.ignore_environments = %w(test development)
    config.environment = Rails.env
  end
end

and when running the asset:precompile task

ASSET_PRECOMPILE=1 RAILS_ENV=production bundle exec rake assets:precompile
like image 95
siliconsenthil Avatar answered Oct 20 '22 18:10

siliconsenthil