-
Notifications
You must be signed in to change notification settings - Fork 363
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
Add compressor options #335
Conversation
This allows specifying Terser options in mangle.json or package.json's "mangle" field.
I've updated the PR with a new config format. The previous Now, in either {
// "minify" for Terser (https://github.com/terser-js/terser#minify-options-structure)
// Note: works as a key in both package.json or mangle.json
"minify": {
// Legacy/convenient way to set mangle.properties.{regex,reserved}:
"properties": "^_",
"reserved": ["_dom", "_constructor"],
// Optionally specify Terser compress configuration.
// Supported values: https://github.com/terser-js/terser#compress-options
"compress": {
"hoist_vars": true,
"reduce_funcs": false
},
// Optionally specify Terser mangle configuration
// Supported values: https://github.com/terser-js/terser#mangle-options
"mangle": {}
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉👍 I always wondered why we didn't just expose the whole terser config.
@marvinhagemeister for now I've left out a couple top-level configuration items like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was gonna ask the same as Marvin but makes sense I guess. Can't you just spread the rest of the config onto Terser instead? If someone passes something specific (without it being documented), that means they want something very specific and they know (I think) what they're doing.
So we document and expose exactly what we want people to actually change, and spread the rest just in case.
@hassanbazzi most of the Terser options folks would want to change are on For Terser's root options, we really can't allow arbitrary customization. Doing so would break output |
This allows specifying Terser options in mangle.json or package.json. The old
"mangle"
field is still supported for legacy reasons alongside the new"minify"
option.This is useful for projects that are already structured with functions aimed at gzip compression optimization.