6.0.2 • Published 1 month ago

postcss-discard-comments v6.0.2

Weekly downloads
8,338,540
License
MIT
Repository
github
Last release
1 month ago

postcss-discard-comments

Discard comments in your CSS files with PostCSS.

Install

With npm do:

npm install postcss-discard-comments --save

Example

Input

h1/* heading */{
    margin: 0 auto
}

Output

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 */).

Note that this module does not handle source map comments because they are not available to it; PostCSS handles this internally, so if they are removed then you will have to configure source maps in PostCSS.

API

comments(options)

options

remove(function)

Type: function Return: boolean Variable: comment contains a comment without /**/

For each comment, return true to remove, or false to keep the comment.

function(comment) {}
var css = '/* headings *//*@ h1 */h1{margin:0 auto}/*@ h2 */h2{color:red}';
console.log(postcss(comments({
    remove: function(comment) { return comment[0] == "@"; }
})).process(css).css);
//=> /* headings */h1{margin:0 auto}h2{color:red}

NOTE: If you use the remove function other options will not be available.

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}

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

cssnano-preset-defaultvuedragdropuploadimages@dubb/mickeycloud-archive-s3bb-chattzar-core@slaty/compiler@fundefund/funde_ckgql_din_mod@olivervorasai/slidercogoportutils@dite/bundler-webpack@aora/aora@aora/types@kova/ssr-plugin-vue3aorb@saaspe/components@kova/ssr-plugin-reactnode-puristexpand-react-bridgesklif-ui-kitsklif-api@everything-registry/sub-chunk-2460@314oner_npm/universal-components-libraryp149-tabletest-popups@claudebernard/bcb-search-barsklif-uireact-lightbox-pack-18supportsequelcomponentsearch-input-reactsearch-list-reactshawki-flatdropfort-module-build-dependenciesstock-ticker-react-widgetes-react-bridgestories-react-bdemr-tabulator-tablesstencil-tailwind-pluginera-ckeditor5sticky-scroll-catchember-tachyons-sweeperssr-plugin-reactssr-plugin-react18ssr-plugin-vuessr-plugin-vue3devosa-tw-uidesign-system-trial-milyasbpademian-builderdolorematquedigital-keyboard-demos@dgrammatiko/joomla-toolscrm-1.0.1@darrenmothersele/builder@darwishdev/dash-dev@csr632/vite@ctfdio/picocss-themes@dimcheify/dimui@dinert/component@dinert/echartsreactjs-tailwindrushirk-my-react-ui-kitrollup-plugin-tailwindcss-litsass-ltr-rtlreactofy-css-libraryresponsis-gantt-task-reactreact-solid-gradient-pickerreui-compilespitballeasyplayer-mydirectus-extension-delete-users-with-filesdirectus-extension-filepreview-interface-sbndirectus-extension-layout-boilerplateedge-postcssedgecssbundlecobacobacarousel-react@beforesemicolon/html-plus@bezael-challenge/innoit-date-format@carbon/bundler@btrb/postcss-plugin@catapult-tech/cp-design-system-build@carhoo/widget-dealerspickupbiz-npm-package@christian-slater/compiler@chancethedev/bundlerpostcss-doctapostcss-arrange@claudebernard/search-bar-elementpostcss-minorispostcss-shopifypostcss-simple-resetpostcss-preset-signalsciences@cloudfour/gulp-tasks@spectrum-css/component-builder@spectrum-css/component-builder-simple@southcn/ckeditor5-build-inline@slater/compiler@syedsadiqali11/emoji-mart@stellaestudio/r2css-postcss-config
6.0.2

1 month ago

6.0.1

4 months ago

6.0.0

1 year ago

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

3 years ago

5.0.0

3 years ago

5.0.0-rc.2

3 years ago

5.0.0-rc.1

3 years ago

5.0.0-rc.0

3 years ago

5.0.0-alpha.0

3 years ago

4.0.2

5 years ago

4.0.1

6 years ago

4.0.0

6 years ago

4.0.0-rc.2

7 years ago

4.0.0-rc.0

7 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago