[英]Heroku Rails 5 App Doesn't Load JavaScript File
I'm trying to deploy a single page Rails 5 app to Heroku, and everything seems to deploy just fine EXCEPT the JavaScript file. 我正在尝试将一个页面的Rails 5应用程序部署到Heroku,并且除了JavaScript文件之外,一切似乎都可以很好地部署。 I have one static.js file within the app/assets/javascripts
folder (besides the application.js). 我在app/assets/javascripts
文件夹中(除了application.js之外)有一个static.js文件。 It all works in localhost, but not when deployed on Heroku. 所有这些都可以在localhost上运行,但是在Heroku上部署时则不能。
I know that it has something to do with precompiling the assets pipeline for Heroku, but I don't really understand how to specifically do that. 我知道这与为Heroku预编译资产管道有关,但是我真的不明白如何具体做到这一点。 Any help or nudge in the right direction would be greatly appreciated! 朝正确方向的任何帮助或推动将不胜感激!
Make sure the config/environments/production.rb
those line like this 确保config/environments/production.rb
这样的行
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
do a git add/commit cycle, then re-deploy to Heroku. 执行git add / commit循环,然后重新部署到Heroku。
Have you tried adding 您是否尝试过添加
config.assets.compile = true
config.public_file_server.enabled = true
to config/environments/production.rb 配置/环境/production.rb
Then, run RAILS_ENV=production rake assets:precompile
然后,运行RAILS_ENV=production rake assets:precompile
git push heroku master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.