postcss-discard-comments
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

postcss-discard-comments Build Status NPM version Dependency Status

Discard comments in your CSS files with PostCSS.

Install via npm:

npm install postcss-discard-comments --save

Example

var postcss = require('postcss')
var comments = require('postcss-discard-comments');

var css = 'h1/* heading */{margin:0 auto}';
console.log(postcss(comments()).process(css).css);

// => 'h1{margin:0 auto}'

This module discards comments from your CSS files; by default, it will remove all regular comments (/* comment */) and preserve comments marked as important (/*! important */) or that refer to a source mapping URL (/*# sourcemap */).

API

comments([options])

options

removeAll

Type: boolean Default: false

Remove all comments marked as important.

var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
console.log(postcss(comments({removeAll: true})).process(css).css);
//=> h1{margin:0 auto}h2{color:red}
removeAllButFirst

Type: boolean Default: false

Remove all comments marked as important, but the first one.

var css = '/*! heading */h1{margin:0 auto}/*! heading 2 */h2{color:red}';
console.log(postcss(comments({removeAllButFirst: true})).process(css).css);
//=> /*! heading */h1{margin:0 auto}h2{color:red}

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
7.0.4673,453latest
5.0.0-rc.2196next
4.0.0-nightly.2020.2.635nightly

Version History

VersionDownloads (Last 7 Days)Published
7.0.4673,453
7.0.3962,934
7.0.228,415
7.0.187,027
7.0.043,885
6.0.21,807,418
6.0.1144,592
6.0.0292,403
5.1.24,911,926
5.1.1202,958
5.1.013,963
5.0.335,150
5.0.236,302
5.0.1266,969
5.0.015,985
5.0.0-rc.2196
5.0.0-rc.11
5.0.0-rc.02
5.0.0-alpha.01
4.0.0-nightly.2020.2.635
4.0.0-nightly.2020.1.111
4.0.0-nightly.2020.1.91
4.0.0-nightly.2020.10.201
4.0.0-nightly.2020.9.92
4.0.0-nightly.2020.9.31
4.0.0-nightly.2020.9.11
4.0.0-nightly.2020.8.291
4.0.0-nightly.2020.8.251
4.0.0-nightly.2020.8.241
4.0.0-nightly.2020.8.171
4.0.0-nightly.2020.8.101
4.0.0-nightly.2020.8.42
4.0.0-nightly.2020.8.12
4.0.0-nightly.2020.7.312
4.0.0-nightly.2020.7.252
4.0.0-nightly.2020.7.241
4.0.22,342,285
4.0.112,943
4.0.03,145
4.0.0-rc.241
4.0.0-rc.01
2.0.4391,211
2.0.311
2.0.21
2.0.11
2.0.02
1.2.15,678
1.2.01
1.1.32
1.1.22
1.1.11
1.1.01
1.0.21
1.0.12
1.0.01

Package Sidebar

Install

npm i postcss-discard-comments@1.0.1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • beneb
  • trysound
  • ludovicofischer
  • ai
  • chriseppstein
  • andyjansson
  • evilebottnawi
  • cssnano-bot