UglifyJS 2: api equivalent for cli -m toplevel?

328 views Asked by At

I'm trying to convert the following command:

uglifyjs src1.js src2.js -c -m toplevel --screw-ie8

to an API call:

ug.minify(['src1.js','src2.js'], {mangle:true, compress:true, ie_proof:false})

But I can't figure out how to set 'toplevel'. Setting toplevel:true or mangle:'toplevel' doesn't work.

1

There are 1 answers

0
Rob W On BEST ANSWER

Put the toplevel option within object literals:

require('uglify-js').minify(['src1.js','src2.js'], {
    mangle: {
        toplevel: true
    },
    compress: true,
    ie_proof: false
});