Heroku构建在uglifier上失败

vbs*_*ql7 15 ruby-on-rails heroku gemfile

我的最小应用程序在本地运行,我没有捆绑错误.但是,当我推送到heroku时,构建在资产期间失败:预编译步骤:

...
Bundle completed (3.24s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompole
rake aborted!
LoadError: cannot load such file -- uglifier
(in /tmp/build_.../app/assets/javascripts/application.js)
Run Code Online (Sandbox Code Playgroud)

注意:
1.我没有在本地使用uglifier gem
2.我没有文件app/assets/javascripts/application.js

我尝试过这些Gemfile解决方案:
A)添加uglifier gem
B)将uglifier添加到资产组
C)从Gemfile中完全删除uglifier并rake卸载所有版本

下一步是什么?

min*_*nic 15

如果要压缩资产,更好的解决方案是添加uglifier到您的GEMFILE:

gem 'uglifier'


小智 14

在config/environments/production.rb中注释这一行

config.assets.js_compressor = :uglifier
Run Code Online (Sandbox Code Playgroud)

  • 不要忘记在下一次推送之前提交!:-) (2认同)

小智 6

如果您有兴趣继续使用uglifier,您可以将其添加到您的Gemfile(并与 Bundler 一起安装)——如@mindtonic 所述。

此外,如果您使用的是 ES6,则需要切换:

config.assets.js_compressor = :uglifier
Run Code Online (Sandbox Code Playgroud)

到:

config.assets.js_compressor = Uglifier.new(harmony: true)
Run Code Online (Sandbox Code Playgroud)

https://github.com/lautis/uglifier/issues/127 中所述