我在heroku上使用webpacker部署了Rails 6应用程序。public / packs与public / assets同步到s3存储桶。从公共/资产工作中转移资产。但是,当尝试打开任何依赖于public / packs的东西时,我会得到。
2020-06-04T05:33:03.622234+00:00 app[web.1]: [58f2d221-761b-44ec-807c-6b922342c10b] method=GET path=/teach/organizations format=html controller=OrganizationsController action=index status=500 error='ActionView::Template::Error: Webpacker can't find admin_unify_style.css in /app/public/packs/manifest.json. Possible causes:
2020-06-04T05:33:03.622242+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2020-06-04T05:33:03.622242+00:00 app[web.1]: unless you are using the `webpack -w` or the webpack-dev-server.
2020-06-04T05:33:03.622243+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2020-06-04T05:33:03.622243+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2020-06-04T05:33:03.622244+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
2020-06-04T05:33:03.622244+00:00 app[web.1]: Your manifest contains:
2020-06-04T05:33:03.622245+00:00 app[web.1]: {
2020-06-04T05:33:03.622245+00:00 app[web.1]: }
heroku应该如何找到有关heroku上的清单的信息。清单包含
"entrypoints": {
"admin_unify_style": {
"css": [
"/packs/css/admin_unify_style-c2ad729a.css"
],
"js": [
"/packs/js/admin_unify_style-62270c86710162620f91.js"
],
"js.map": [
"/packs/js/admin_unify_style-62270c86710162620f91.js.map"
]
更新1:它正在heroku之外的生产环境中工作,并且在Cloudfront上没有资产
长话短说-清单应该在heroku上,而资产可以在s3上
public/assets/*
!public/assets/.sprockets-manifest*
public/packs/*
!public/packs/manifest.json*
但是您可以看到清单不是。
config.action_controller.asset_host = "https://blabla.cloudfront.net"
if git ls-files -m | grep "public/assets/.sprockets-manifest\|public/packs/manifest.json*"; then
git add --all public/assets/.sprockets-manifest* -f
git add --all public/packs/manifest.json* -f
git commit -m "Autocompiling assets from jenkins"
git push
fi
这样,我们在回购中只有两个清单,所有资产都在S3上。5.推到heroku,它起作用。现在,就像魅力