Next.js: UglifyJs: “Invalid assignment” – support for uglify-es?

Created on 26 Oct 2017  Â·  5Comments  Â·  Source: vercel/next.js

I'm getting “Invalid assignment” from UglifyJs in next build, so I've been forced to disable UglifyJs for now.

Anyone been able to migrate to uglify-es
(with support for ES2015+/ES6+)?

Most helpful comment

try to use [email protected] and modify your next.config.js

config.plugins = config.plugins.filter(p =>
  p.constructor.name !== 'UglifyJsPlugin'
)

if(!dev) {
  const Uglify = require('uglifyjs-webpack-plugin')
  config.plugins.push(
    new Uglify({
      parallel: true,
      sourceMap: true
    })
  )
}

All 5 comments

What about Babel Minify and do more changes? #3056

try to use [email protected] and modify your next.config.js

config.plugins = config.plugins.filter(p =>
  p.constructor.name !== 'UglifyJsPlugin'
)

if(!dev) {
  const Uglify = require('uglifyjs-webpack-plugin')
  config.plugins.push(
    new Uglify({
      parallel: true,
      sourceMap: true
    })
  )
}

Thank you @IanWang! It worked great.

ive added config, and now my next.config.js look like this: module.exports = {
webpack: function ( config ) {
if ( config.resolve.alias ) {
delete config.resolve.alias['react'];
delete config.resolve.alias['react-dom']
}
config.plugins = config.plugins.filter ( p =>
p.constructor.name !== 'UglifyJsPlugin'
);
const dev = process.env.NODE_ENV !== 'production';

    if ( !dev ) {
        const Uglify = require ( 'uglifyjs-webpack-plugin' );
        config.plugins.push (
            new Uglify ( {
                parallel:  true,
                sourceMap: true
            } )
        )
    }
    return config
}

};
`

But now after successfull build, deploy , by useing now stuck at

Using "webpack" config function defined in next.config.js.
Whats wrong with this?
@ @ #

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings