-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Use Terser for minifying production build #5021
Comments
In your tweet you pointed out improved build times, could you provide data backing this up? Just curious about it, I definitely think we need to make this move 👍 |
The first run is the default Next.js webpack configuration (so it's using Uglify);
The second is with the terser webpack plugin enabled;
I am not that of an export of Babel / Webpack performance, but it can also be that there is some caching involved? |
Hmm it seems if I run the build multiple times, the build times do not differ that much (+/- 5s). |
The best thing you can do when benchmarking is |
https://github.com/babel/minify#benchmarks you're right that it's faster |
I've ran both builds again with my caches cleared, but the difference is in 2 or 3 seconds most of the time. So it's not that much faster. But if you look at projects like Parcel, it seems the way to go to minify es6 code with terser. Is there anything I can do to get terser into Next? As I mentioned, the config changes are not that hard and I have the time to create a PR for it to continue the discussion. |
Yeah the only thing you'll have to do is add the config you mentioned in the issue description. |
This is the result for zeit.co production build: Default webpack / Uglify:
Terser:
|
Feature request
Is your feature request related to a problem? Please describe.
Currently Next.js minifies the production build with Uglify. Unfortunately,
uglify-es
is no longer maintained anduglify-js
does not support es6+ syntax very well. It would be nice to make the same move as Parcel to use the terser library.Describe the solution you'd like
Webpack v4 has already a compatible terser plugin, which could be enabled quite easily;
I already did this on one of my projects which currently runs in production and haven't run into any issues yet. I even noticed some improvements on the build time. Also the sourcemaps work as expected.
Describe alternatives you've considered
An alternative would be to create a
next-terser
plugin to let people have the option to opt-in if they want.The text was updated successfully, but these errors were encountered: