Heroku在部署时不会预编译资产 [英] Heroku does not precompile assets when deploying
问题描述
诚然,我没有兴趣在本地预编译这些代码。
production.rb 中的内容,我在 application.rb 在我的 production.rb 中:
config.serve_static_assets = false
config.assets.compile = false
config.assets.precompile<< 'application.js'
config.assets.precompile<< 'application.css'
config.assets.precompile<< 'screen.css'
然后我进行部署,然后返回:
----->编译嵌入大小:52.4MB
----->启动... done,v28
http://myapp.herokuapp.com部署到Heroku
<所以它编译了一些东西,对吧?除非没有去,我去了网站,.css和.js文件是空白的。
为了在本地进行预编译,我需要在<
@importscreen.css.scss; / strong> bootstraps_and_overrides.css 行:
然后在本地进行预编译,我的本地计算机不会正确加载css,但远程执行 现在我的部署方法是注释掉那行代码,
bundle exec rake资源:预编译
git add。
git commit -m添加公共/资产
git push heroku开发:master
然后(不幸!):
bundle exec rake assets:clean
然后在我的.css中取消注释该行代码。
它不会部署的原因是因为Google字体。将文件移动到application.css中,例如:
* = require_self
* = require_tree。
* /
@import url(http://fonts.googleapis.com/css?family=Special+Elite);
将允许应用程序进行部署,并使字体正常工作。 b
It very clearly says in its documentation that it would do this if I don't precompile them locally.
And truthfully, I have no interest in precompiling these locally.
What I've had in production.rb, I've duplicated in application.rb
In my production.rb :
config.serve_static_assets = false
config.assets.compile = false
config.assets.precompile << 'application.js'
config.assets.precompile << 'application.css'
config.assets.precompile << 'screen.css'
Then I deploy, and that returns :
-----> Compiled slug size: 52.4MB
-----> Launching... done, v28
http://myapp.herokuapp.com deployed to Heroku
So it "compiled" something, right? Except no go, I go to the site and the .css and .js files are blank.
In order to precompile this locally, I am required to comment out in bootstraps_and_overrides.css the line :
@import "screen.css.scss";
Then it precompiles locally, and my local machine will not load the css correctly, but remotely it will actually work correctly.
So my method of deployment now is comment out that line of code,
bundle exec rake assets:precompile
git add .
git commit -m "Adding public/assets"
git push heroku development:master
Then ( unfortunately! ) :
bundle exec rake assets:clean
And then uncomment that line of code in my .css.
The reason it would not deploy was because of Google fonts. Moving the file to your application.css such as :
*= require_self
*= require_tree .
*/
@import url(http://fonts.googleapis.com/css?family=Special+Elite);
Will allow the app to deploy, and for the fonts to work.
这篇关于Heroku在部署时不会预编译资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!