Please allow a way for us to configure which options the terser module uses when uglying the output production code. It looks like -m -c are being hard-coded in Parcel.
In some configuration file or within my package.json, I can specific which options to execute terser with.
I have no control over how terser runs.
We need more control of how terser generates our output. Specifically, we'd like to use --toplevel.
Full listing of all available options for terser can be found here: https://www.npmjs.com/package/terser
You can configure it using a terserrc or uglifyrc file
Sent with GitHawk
Care to elaborate? This isn't documented anywhere.
When I add either a .terserrc or .uglifyrc file with an appropriate configuration, it doesn't change anything.
You can have a look at the source starting here: https://github.com/parcel-bundler/parcel/blob/master/src/transforms/terser.js#L10
I think this has something to do with resolving of the config file and #1405 .
Why is this issue closed? I looked at terser.js, but whatever I add in my .terserrc, it isn't taken into account. E.g., when using
{
  "output": {
    "comments": true
  }
}
all comments are still stripped when running parcel build.
The file should be in the same directory as package.json, shouldn't it?
@marcelkorpel have you tried clearing the parcel cache and dist folders?
@stevensun32 Yes, I did, just tried again, but it seems the contents of .terserrc aren't taken into account at all, all comments simply get stripped. Is my syntax still correct?
My bad, terser is a javascript minifyer, and I am looking at my CSS, which is processed by postcss. I'm sorry for my mistake!
Most helpful comment
Care to elaborate? This isn't documented anywhere.
When I add either a
.terserrcor.uglifyrcfile with an appropriate configuration, it doesn't change anything.