天天看點

有關asset pipeline與stylesheets檔案位置有關asset pipeline與stylesheets檔案位置

有關asset pipeline與stylesheets檔案位置

如檔案中引用stylesheets檔案如下:

<%=stylesheet_link_tag 'blueprint/print', :media=>'print'%>
<%=stylesheet_link_tag 'blueprint/screen', :media=>'screen'%>
           

即引用bluepint下的print.css和screen.css。

step1: .css檔案位置。

           預設引用位置為assets/stylesheets,是以需要将blueprint放在stylesheets檔案夾下。也可以放置在public/assets/stylesheets下。

step2: assets precompile。

           需要将檔案放在assets/stylesheets下,assets/stylesheets檔案夾下建立contrlloer時會自動生成對應的.css及.scss檔案,如果需要另外的.css檔案需要在config/environment/production.rb檔案中指定對應檔案的位置,即添加:

config.assets.precompile += ['blueprint/print.css', 'blueprint/screen.css']
           

           同時,heroku要求在config/application.rb中配置:

config.assets.initialize_on_precompile=false
           

           以上配置參考連結:http://guides.rubyonrails.org/asset_pipeline.html

step3:assets的precompile可以分三種方式,具體參照如下連結。

(推薦的是在git push heroku時由heroku自動編譯,也就是有上述配置之後,不需要再有更多的操作。)

           https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar

繼續閱讀