With cleanup, you have:
Please see Whats New, cleanup v2.0.0 requires node v4.2 or above.
Why not Uglify?
Uglify is a excelent minifier but you have little control over the results, while with cleanup your coding style remains intact and removal of comments is strictly under your control.
npm install rollup-plugin-cleanup --save-dev
You can restrict the accepted files using the options
extensions (see below).
By default, only the .js, .jsx, and .tag files are processed, but it can be useful for any non-binary file if you skip the JS parsing by setting
comments to "all" and the
include option to the desired extensions.
||Filter or array of filter names and/or regexes. Use "all" to keep all, or "none" to remove all the comments.|
||Use a positive value or
||Allowed values: "unix", "mac", "win".|
||For the JS parser, change it to "script" if necessary.|
||minimatch or array of minimatch patterns for paths to include in the process.|
||minimatch or array of minimatch patterns for paths to exclude of the process.|
||String or array of strings with extensions of files to process.|
* Emission of source map honors the Rollup
sourcemap (lowercased) options.
See the regexes in src/parse-options.js
|license||Preserve comments with the word "@license" inside.|
|some||Like the uglify default: "@license", "@preserve", "@cc_on"|
|ts3s:||TypeScript Triple-Slash Directives|
|srcmaps||Source Map (inlined or external)|
You can set custom filters through regexes that matches the content of the comments that you want to preserve
(multiline comments begins with an asterisk (
*), one-line comments begins with a slash (
This filter will preserve multiline comments starting with a dash, in addition to eslint directives:
* Contributions and stars are welcome...