-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Heroku deploy error related to Webpacker compile (specifically UglifyJS: unexpected token: punc (,)) #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Was able to resolve this by using the beta version of uglifyjs-webpack-plugin, which depends on uglify-es 3. Saw multiple suggestions in various places to use uglify-es, but it seems that the fix I needed was in version 3.0 while the webpack plugin is currently using 2.8.29. A maintainer over at UglifyJS2 was able to point me in the right direction. After a bunch of trial and error, this discussion helped me finally resolve. Then, in production.js I made the following adjustments per the uglify-webpack-plugin instructions:
Hope this is helpful to others experiencing this issue. |
Any idea how "update" |
@hovancik You can delete the default uglify plugin and add this one like so: https://github.com/rails/webpacker/blob/master/docs/webpack.md#loaders https://github.com/rails/webpacker/blob/master/package/environments/production.js#L11 // production.js
environment.plugins.delete('UglifyJs')
environment.plugins.set('UglifyJs', /* new plugin */) |
For others with the same problem, I had to install the latest uglify-webpack-plugin:
And then do this in
I'm new to webpack, so I'm not sure this is the right way to do things, but it allowed me to precompile on Heroku, combining sprockets assets and my webpack components. |
@bborn Thanks, I had same problem, solved for me as well. |
Attempting to deploy to Heroku using webpacker. Read through #280 and followed instructions in #291. App in question is using Elm (i.e., rails new myapp --webpack=elm). After running
git push heroku
, the Webpacker compile error (from the Heroku remote) is:remote: ERROR in hello_elm-19337190dd5fe89758f3.js from UglifyJs remote: Unexpected token: punc (,) [./node_modules/mathsteps/lib/node/index.js:11,0][hello_elm-19337190dd5fe89758f3.js:1870,9]
Environment:
Ubuntu 14.04.5 LTS
Node: 6.11.0
Yarn: 0.22
Rails: 5.1.2
Webpacker: 2.0
Uglifier: 3.2.0
Webpack: 3.3.0
package.json:
The content of the identified file, from the mathsteps repo, is below. This file is unchanged in the forked version I'm using, and the error persists when I use the mathsteps master branch:
hello_elm.js
calls mathsteps viaimport mathsteps from 'mathsteps';
(consistent with the default import forhello_elm.js
:import Elm from './Main';
) and uses it vialet expressionSteps = mathsteps.simplifyExpression(inpBarEnt.expression);
webpack-dev-server
runs fine locally.I'll also post this issue at https://github.com/mishoo/UglifyJS2 and report a fix if one comes through.
Thanks in advance for any help you can provide.
The text was updated successfully, but these errors were encountered: