stripcomment-loader
v0.1.0
Published
WebPack plugin to effectively strip comments
Downloads
8,259
Readme
stripcomments-loader
- A tiny loader to blanken your code.
While using UglifyJS over WebPack, I realized that the comments weren't stripped, actually. So I decided to write this loader that processes files and cleans them from comments - EXCEPT when debugging is enabled.
Usage
It's recommended to use this as a preLoaders
entry to process multiple files that use either //
or /* ... */
as comment indicators. Examples include JavaScript and CSS.
module.exports = {
entry: "./test.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
preLoaders: [
{
test: /\.(js|css)$/,
loader: "stripcomments?-lines"
}
]
}
}
Now just require any JS or CSS file, and you should see comments getting stripped.
To retain comments, set debug: true
. In this case, comments are kept in-place.
Query options
You can control which and what is stripped:
stripcomments?-block
This will only strip block comments. Adding -line
will only strip line comments. Supplying both or none, then all will be stripped. Passing +safe
will have extra effects on which comments are to be removed.