Why does rake assets:precompile in development cause problems but not in my production environement

亡梦爱人 提交于 2019-12-10 09:25:15

问题


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.

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.

In environments/production.rb

config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true

In environments/development.rb

config.assets.compress = false
config.assets.debug = true
config.assets.compile = true

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


回答1:


Ok i seem to have solved it.

In environments/development.rb change this line

config.assets.debug = true

to this

config.assets.debug = false

Not sure why this works but from reading the rails guides and quote:

"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.



来源:https://stackoverflow.com/questions/10520724/why-does-rake-assetsprecompile-in-development-cause-problems-but-not-in-my-prod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!