TrySound / rollup-plugin-uglify

Rollup plugin to minify generated bundle
MIT License
260 stars 42 forks source link

Plugin don't support "include" and "exclude" #54

Open suanmei opened 5 years ago

suanmei commented 5 years ago

I want to generate two versions of the file

So I need it to let me choose to compress or not compress for a file by include or exclude

Just like uglifyjs-webpack-plugin

TrySound commented 5 years ago

This plugin is able to transform only bundles, not specific files. So these options just doesn't make sense. As a solution you may use condition

[
  ...
  condition && uglify()
  ...
]
suanmei commented 5 years ago

yeah,I just want to specify the bundle like that

uglify({
  include: '/\.min\.js$/'
})
suanmei commented 5 years ago

This is too simple for you to add two apis

transformBundle(code, options) {
  yourFunc(options.file)
  ...
  ...
}
TrySound commented 5 years ago

This won't work if chunk names are autogenerated

TrySound commented 5 years ago

I think I would accept this feature. Could you prepare a PR?

suanmei commented 5 years ago

Completely fine

suanmei commented 5 years ago

UglifyJs can‘t accept options other than the one it specifies, so ---

do you want me to change your options format like that

{
  include: /\/includes/,
  exclude: /\/exclude/,
  uglifyOptions: {} // uglifyJS API options
}

and change the version to 7.0.0, so it won't affect the previous users

or

let me do some compatibility with versions prior to 6.0.0 and 6.0.0, such as removing include and exclude before passing options to uglifyJS, which is not conducive to extending new features in the future.

suanmei commented 5 years ago

I looked at the latest documentation. If you don't specify a filename, it won't automatically generate a new filename, but instead output it directly to the command line tool.

suanmei commented 5 years ago

@TrySound look forward to your reply

TrySound commented 5 years ago

I set sourceMap to undefined, look at the code