css - Rails How to include a scss file in a specific erb view? -
this question has answer here:
i want include assets/stylesheets/work.scss
file in view/work/index.html.erb
i've check question
how include css or javascript in erb outside layout?
and add in layout/application.html.erb
<head> ... <%= yield(:header) if content_for? :header%> </head>
then, add in index.html.erb
<% content_for :header -%> <%= stylesheet_link_tag 'work' %> <% end -%>
i doing in development
mode instead of production
, why need precompile
?
because including independently, , not including in application.css
. default asset pipeline compile applicaiton.css/application.js
, included in files.
/* * manifest file that'll compiled application.css, include files * listed below. * * css , scss file within directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or plugin's vendor/assets/stylesheets directory can referenced here using relative path. * * you're free add application-wide styles file , they'll appear @ bottom of * compiled file styles add here take precedence on styles defined in styles * defined in other css/scss files in directory. better create new * file per style scope. * *= require_tree . *= require c3 *= require purecss *= require_self *= require pure_css_reset */
if want seperate , not compiled 1 monolithic file, being called stylesheet_link_tag
, have manually add precompile array.
http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets reference.