rhunwicks commented on issue #3973: uglifyjs-webpack-plugin@^0.4.6 and 
uglifyjs-webpack-plugin@^1.1.0 both in use
URL: 
https://github.com/apache/incubator-superset/issues/3973#issuecomment-385961205
 
 
   Our attempt to build the JavaScript assets is failing with:
   
   ```
   ERROR in dashboard.e12007b38f5d226a9398.entry.js from UglifyJs
   Unexpected token: keyword (const) 
[dashboard.e12007b38f5d226a9398.entry.js:250449,7]
   
   ERROR in explore.b068173a7061b4b69f89.entry.js from UglifyJs
   Unexpected token: keyword (const) 
[explore.b068173a7061b4b69f89.entry.js:250450,7]
   ```
   
   
https://stackoverflow.com/questions/42375468/uglify-syntaxerror-unexpected-token-punc/46294198#46294198
 explains that the installed `"uglifyjs-webpack-plugin": "^1.1.0",` from 
`package.json` won't get used.
   
   We solved the problem by removing the embedded Webpack version prior to 
running the build:
   
   ```
   rm -rf ./node_modules/webpack/node_modules/uglifyjs-webpack-plugin
   npm run prod
   ```
   
   Once the desired `"uglifyjs-webpack-plugin": "^1.1.0",` was being used we 
had to update the `webpack.config.js` to match the config requirements for the 
later package:
   
   ```javascript
   const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
   
   if (process.env.NODE_ENV === 'production') {
     // Using settings suggested in 
https://github.com/webpack/webpack/issues/537
     const UJSplugin = new UglifyJsPlugin({
       uglifyOptions: {
         ecma: 8,
         compress:  {
           warnings: false
         },
       },
       sourceMap: true,
       parallel: 4
     });
     config.plugins.push(UJSplugin);
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to