Rails 3: asset pipeline + lots of layouts

I have a huge project with rails 3.1 (without conveyor without assets). There are many different layouts in this project, for example:

  • application
  • at home
  • console

Etc. Each layout has a huge list of js and css (for their attachment we use javascript_include_tag and stylesheet_link_tag ). Is it possible to enable the asset pipeline so that it includes different js / css files for different layouts and it will generate different application.js and application.css for each layout during production?

+6
source share
1 answer

Yes it

application.css

 *= require this_file *= require that_file 

home.css

 *= require this_file *= require home_file 

etc.

you can do this in your application layout:

  <%= stylesheet_link_tag "application", media: "all" %> 

and home layout

  <%= stylesheet_link_tag "home", media: "all" %> 

you will also need to configure production.rb

  config.assets.precompile += %w( application.css home.css home.js ) 

including all compiled files that you reference in the layouts.

+18
source

Source: https://habr.com/ru/post/944510/


All Articles