Package Exports
- strip-css-comments
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strip-css-comments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
strip-css-comments 
Strip comments from CSS
Also available as a gulp/grunt/broccoli plugin.
Usage
$ npm install --save strip-css-commentsvar stripCssComments = require('strip-css-comments');
// by default important comments `/*!` are preserved
stripCssComments('/*! <copyright> */ body { /* unicorns */color: hotpink; }');
//=> '/*! <copyright> */ body { color: hotpink; }'
// `preserve: false` will strip all comments including `/*!`
stripCssComments(
'/*! <copyright> */ body { /* unicorns */color: hotpink; }',
{preserve: false}
);
//=> 'body { color: hotpink; }'
// preserve comments based on a regex
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{preserve: /^#/}
);
//=> '/*# preserved */ body { color: hotpink; }'
// preserve comments based on the return value of the supplied function
stripCssComments(
'/*# preserved */ body { /* unicorns */color: hotpink; }',
{
preserve: function (comment) {
return comment.charAt(0) === '#';
}
}
);
//=> '/*# preserved */ body { color: hotpink; }'API
stripCssComments(input, [options])
input
Required
Type: string
String with CSS.
options
preserve
Type: boolean, RegExp, function
Default: true
true- Preserve comments that use the/*! */syntaxfalse- Strip all commentsRegExp- Preserve comments where the comment body matches a regular expression.Function- Preserve comments for which a function returnstrue. The function is called on each comment, gets the comment body as the first argument, and is expected to return a boolean of whether to preserve the comment.
CLI
$ npm install --global strip-css-comments$ strip-css-comments --help
Usage
$ strip-css-comments <input-file> > <output-file>
$ strip-css-comments < <input-string>
Option
-a, --all Strip all comments including `/*!`
Example
$ strip-css-comments src/app.css > dist/app.css
$ strip-css-comments < src/app.css --allBenchmark
$ npm run benchRelated
License
MIT © Sindre Sorhus