当我推送到heroku时,我的application.css没有改变。
rake assets:precompile # does some things
git add-commit -m "..."
git push heroku master
Application.css:
*
*= require foundation_and_overrides
* required other files
*/
body {
background: red
}
生产环境:
config.assets.compile = true
config.assets.digest = true
没有任何效果,即使将背景设置为红色,我的背景也是白色。 请问管道如何与heroku和rails 5配合使用?
您需要运行bundle exec rake assets:precompile RAILS_ENV=production
,否则它将使用开发环境配置设置进行预编译。 另外,为了强制更改指纹摘要,我希望您在application.css文件的最顶部添加一个注释,使其看起来像这样:
/assets/stylesheets/application.css
/* Adding a comment to force a new digest and expire cached assets in browsers */
另外,请确保在您的gemfile中包括用于提供资产的heroku gem:
gem 'rails_12factor', group: :production
另外,作为附带说明,您在设置config.assets.compile = true
时要求性能大幅下降
在部署到生产环境并保留资产之前,您应确保找到所有丢失的资产并修复资产路径。compile= false