Webpack-encore: Change From uglify to terser

Created on 18 Oct 2018  路  4Comments  路  Source: symfony/webpack-encore

Encore requires uglifyjs-webpack-plugin in version ^1. This leads to issues when uglifying es2015+ code as only version ^2 supports it.

See https://github.com/webpack/webpack/issues/5858#issuecomment-338144186

HasPR

Most helpful comment

I agree. It seems like terser is the future and we should change to it before the next release (because it already contains so many other changes).

All 4 comments

Hi @dmolineus,

I don't think that's the case based on this changelog.

After its next release Encore will include webpack 4 and uglifyjs-webpack-plugin ^1.2.5 which uses uglify-es (and thus supports ES6).

If we update uglifyjs-webpack-plugin to 2.x, it will use uglify-js again and ES6 won't be supported anymore.

However what we could do is follow their advice to use terser-webpack-plugin instead. It seems that it's going to replace the uglifyjs-webpack-plugin in Webpack 5.

@Lyrkan Thanks for looking deeper and pointing out that 2.x of uglifyjs-webpack-plugin won't help. Maybe it would be at least useful if a user can disable the default minifying shipped with Encore. So it would be possible to use another tool if required.

Well, the default tool should be changed to be terser-webpack-plugin IMO

I agree. It seems like terser is the future and we should change to it before the next release (because it already contains so many other changes).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EliuTimana picture EliuTimana  路  4Comments

JohnnyEvo picture JohnnyEvo  路  3Comments

rebangm picture rebangm  路  4Comments

mstrom picture mstrom  路  3Comments

Growiel picture Growiel  路  4Comments