Reputation: 12923
So consider the following script command to run via npm run
: webpack -p --optimize-minimize
Is there any way to say: Keep comments?
webpack version 2 is used.
In most applications you would not want to keep comments, but in this particular case I want to keep them, while still minifying the "script" Is this possible?
Upvotes: 2
Views: 3539
Reputation: 10419
Webpack's webpack.optimize.UglifyJsPlugin
has a couple of options which might fit your needs.
comments
options accepts a regex or function to tell UglifyJs
which comment to preserve.
extractComments
let you even extract the comments to separate txt files.
Set it up like this:
plugins: [
new webpack.optimize.UglifyJsPlugin({
comments: true, // or function/regex
// Further UglifyJs config
})
],
Upvotes: 3