为什么掠夺资产:在开发中进行预编译会引起问题,但在我的生产环境中却不会 [英] Why does rake assets:precompile in development cause problems but not in my production environement
问题描述
我已将我在Heroku上的应用程序升级到雪松堆栈,以便资产管道正常工作.通过选择在本地编译资产,我遵循了 heroku的文档中给出的说明.
I have upgraded my app on heroku to a cedar stack so that the asset pipeline works. I have followed the instructions given in heroku's docs by choosing to compile assets locally.
这已创建目录public/assets.生产中的所有内容都能完美运行(css,js,没有问题).回到我的开发环境似乎导致js无法正常运行.
This has created a directory public/assets. Everything in production works perfectly(css, js, with no problems). Going back to my development environment seems to cause the js to not function properly.
在 environments/production.rb
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
在 environments/development.rb
config.assets.compress = false
config.assets.debug = true
config.assets.compile = true
我已经检查了源页面,并且所有文件都正确加载,没有重复的条目.我已经阅读了一些关于是否在本地还是在生产中编译资产的问题,但是似乎没有一个问题.恢复我的开发javascript代码还有其他遗漏吗?这是要遵循的正确步骤吗?谢谢
I have checked the source page and all files get loaded correctly with no duplicate entries. I have read some SO questions about whether to compile assets locally or in production but none of them seem to help. Is there something else that i am missing to restore my development javascript code and is this the correct procedure to follow? Thank you
推荐答案
好,我似乎已经解决了.
Ok i seem to have solved it.
在environment/development.rb中,更改此行
config.assets.debug = true
对此
config.assets.debug = false
不确定该方法为何有效,但请阅读Rails指南并引用:
Not sure why this works but from reading the rails guides and quote:
当调试模式关闭时,Sprockets会串联并在所有文件上运行必要的预处理器.在调试模式关闭的情况下,上面的清单会生成:"
"When debug mode is off, Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead:"
<script src="/assets/application.js" type="text/javascript"></script>
希望这可以帮助遇到类似问题的人.
Hope this helps someone with similar issues.
这篇关于为什么掠夺资产:在开发中进行预编译会引起问题,但在我的生产环境中却不会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!