Parcel: Allow configuration of terser options

Created on 20 Jul 2018  路  8Comments  路  Source: parcel-bundler/parcel

馃檵 feature request

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.

馃 Expected Behavior

In some configuration file or within my package.json, I can specific which options to execute terser with.

馃槸 Current Behavior

I have no control over how terser runs.

馃敠 Context

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

Waiting Question

Most helpful comment

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.

All 8 comments

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.

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!

Was this page helpful?
0 / 5 - 0 ratings