我应该从gitignore(rails-webpacker-Heroku)中删除/ public / packs

时间:2019-01-12 10:47:49

标签: ruby-on-rails heroku webpack webpacker

我最近在加载包含webpacker packs的页面时遇到问题。

2019-01-12T10:24:46.804323+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df] ActionView::Template::Error (Webpacker can't find flavour.js in /app/public/packs/manifest.json. Possible causes:
2019-01-12T10:24:46.804326+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2019-01-12T10:24:46.804327+00:00 app[web.1]:    unless you are using the `webpack -w` or the webpack-dev-server.
2019-01-12T10:24:46.804329+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2019-01-12T10:24:46.804331+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2019-01-12T10:24:46.804332+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
2019-01-12T10:24:46.804334+00:00 app[web.1]: Your manifest contains:
2019-01-12T10:24:46.804335+00:00 app[web.1]: {
2019-01-12T10:24:46.804337+00:00 app[web.1]: }
2019-01-12T10:24:46.804338+00:00 app[web.1]: ):
2019-01-12T10:24:46.804578+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df]     1: <%= javascript_pack_tag("flavour") %>
2019-01-12T10:24:46.804580+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df]     2: <%= javascript_pack_tag("beans") %>
2019-01-12T10:24:46.804582+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df]     3: <%= javascript_pack_tag("roasterselector") %>
2019-01-12T10:24:46.804583+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df]     4: <%= javascript_pack_tag("styleselector") %>
2019-01-12T10:24:46.804636+00:00 app[web.1]: [66341a26-d0f1-4020-bd85-495d199087df]

我已经尝试了很多方法来解决它:

  • 将webpack-dev-server从devDependencies移至package.json中的Dependencies
  • 设置config.assets.compile = true
  • 运行了$ rails assets:precompile RAILS_ENV=production

这些都不起作用。

我终于从我的public/packs文件中删除了.gitignore,这似乎已经解决了吗?

这是正确的做法吗?我压缩后的推送大小已从88mb变为222mb。

有趣的是,我注意到我的public / packs文件夹中的包有很多变体。这是正确的吗?

enter image description here

1 个答案:

答案 0 :(得分:0)

在提交前执行bundle exec rails webpacker:clobber