Been trying to push this to production, but I'm always getting these errors on build:
{ Error: bundles/pages/index.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [bundles/pages/index.js:5913,58]
at /var/www/apps/cg-stage/node_modules/next/dist/server/build/index.js:133:21
at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:256:15
at Compiler.emitRecords (/var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:351:37)
at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:249:12
at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:344:11
at next (/var/www/apps/cg-stage/node_modules/tapable/lib/Tapable.js:154:11)
at Compiler.compiler.plugin (/var/www/apps/cg-stage/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at next (/var/www/apps/cg-stage/node_modules/tapable/lib/Tapable.js:156:14)
at done (/var/www/apps/cg-stage/node_modules/sw-precache-webpack-plugin/lib/index.js:172:18)
errors:
[ 'bundles/pages/index.js from UglifyJs\nSyntaxError: Unexpected token: operator (>) [bundles/pages/index.js:5913,58]',
'bundles/pages/_document.js from UglifyJs\nSyntaxError: Unexpected token: operator (>) [bundles/pages/_document.js:1791,64]' ],
warnings: [] }
I've always had these UglifyJs errors with Next, but it would build correctly. Now it's not building any more.
It's a regression between this module and Uglify. Try to contact owners of that module or use a substitute.
Or you can turn off UglifyJS like this:
// next.config.js
module.exports = {
webpack(cfg) {
cfg.plugins = cfg.plugins.filter(plugin => {
if (plugin.constructor.name === "UglifyJsPlugin") {
return false;
} else {
return true;
}
});
return cfg;
}
};
Just to point out, besides onfontready I found that react-fittext also breaks things.
@arunoda @luandro I get the same uglify error on build, how did you find out which modules cause it?
I had to manually check which of my components were causing it. Donno if there's a better way.
@fridays same way @luandro found it out.
Thanks
Most helpful comment
Just to point out, besides
onfontreadyI found that react-fittext also breaks things.