With cleanup, you have:
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 "include", "exclude", and "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 the option
comments: 'all' in the plugin and
include option with 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 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 in the process.|
||String or array of strings with extensions of files to process.|
* Source Map support is given through the Rollup
Se the regexes in src/parse-options.js
|license||Preserve comments with "@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:
"ts3s"to preserve TypeScript Triple-Slash Directives (See NOTE)
* For me, write in english is 10x harder than coding JS, so contributions are welcome...