我一直在使用 Webpacker 在生产环境中部署 Rails 应用程序。
背景:我正在开发一组自定义的 Rails 模板,目的是减少新应用程序激增时的摩擦。由于我的想法是快速构建和部署新应用程序,因此我决定使用 Webpack(因为这就是冰球的发展方向)。我使用模板在虚拟机上创建了 3 个应用程序。我能够获得三个部署和加载图像、样式等之一......但我缺少其他两个的一些东西。 [* 当我创建第一个应用程序时,我正在迭代模板。]
服务器设置:
- Ubuntu 17.10 x64
- Rails 5.2.rc1
- ruby 2.5
- Nginx
- 彪马
- Webpacker
- Capistrano 3.10.1
应用程序:(一个有效,一个不太有效)
第一个:(这是正在工作的)
https://github.com/dschmura/davechmura_website
第二:(不工作)
https://github.com/dschmura/arborguide_website
当我查看生产日志时,我得到了这个
ERROR:
ActionView::Template::Error (Webpacker can't find application.css in /home/deployer/apps/arborguide_website/releases/20180224143553/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
此外,arborguide_website/current/public/packs 目录为空。我猜我需要解决#4,但我一辈子都无法弄清楚它是如何为 davechmura.com 应用程序而不是其他应用程序工作的。
我通常会更早举手,但我对 Webpacker 相对较新,并且认为最好更多地探索该领域。然而现在,我真的陷入了困境。
最佳答案
您的Capfile已将 capistrano/rails
注释掉:
# require 'capistrano/rails'
这意味着 cap deploy
不会自动运行 assets:precompile
,而这正是触发 webpack 构建的原因。
关于ruby-on-rails - Webpacker 部署到生产环境时未为 Rails 5.2 中的某些应用程序创建 list ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48967256/