Heroku Webpacker的资产在s3上-在清单中找不到资产

问题描述 投票:0回答:1

我在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 amazon-s3 webpack webpacker
1个回答
0
投票

长话短说-清单应该在heroku上,而资产可以在s3上

[这是我的工作方式-Heroku,S3,Cloudfront,Webpacker,Rails 6,Sprockets。

  1. 资产已预编译并上传到s3。从仓库中忽略了public / assets和public / packs。
public/assets/*
!public/assets/.sprockets-manifest*
public/packs/*
!public/packs/manifest.json*

但是您可以看到清单不是。

  1. 将Cloudfront配置为使用]进行生产>
  2.   config.action_controller.asset_host = "https://blabla.cloudfront.net"
    
  1. public / assets和public / fonts在s3上使用s3cmd命令进行同步。自定义脚本。
  2. 同步到s3之后,我们将提交清单
  3. 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,它起作用。现在,就像魅力

© www.soinside.com 2019 - 2024. All rights reserved.