Rails 4 Assets Precompilation with multiple manifest files

ruby-on-rails-4

I have a rails 4 application.

I have 3 sets of manifest files in order to seperate out logic for my app.

These files are

application.js
backoffice.js
pos.js

application.css
backoffice.css
pos.css

In my layout files, I reference these assets using the associated javascript_link_tags

I have added the following to my production.rb file (in order to include these files in the precompilation of assets):

config.assets.precompile += %w( backoffice.js pos.js pos.css backoffice.css )

I then run rake assets:precompile, but it is not picking up the additional files.
It only compiles the application.js and application.css manifests.

In production.rb also, I have:

config.serve_static_assets = true
config.assets.compile = false

Anyone any ideas?

thanks

Best Answer

If you copy this line

config.assets.precompile += %w( backoffice.js pos.js pos.css backoffice.css )

to config/application.rb (Rails 4.0) (instead of config/environments/production.rb) it will work.

I've got a tip from here: Rails 4 assets.precompile

As suggested in the comments, in Rails 4.2 you should write above line in config/initializers/assets.rb

Related Topic