postcss-optional-comments

A PostCSS plugin for conditional comments

Usage no npm install needed!

<script type="module">
  import postcssOptionalComments from 'https://cdn.skypack.dev/postcss-optional-comments';
</script>

README

postcss-optional-comments postcss-optional-comments CircleCI Project postcss-optional-comments on NPM

Support for conditional comments using PostCSS.

What does this do?

This plugin allows you to choose which comments will appear in your css output using a simple not operator, /*!, in the opening syntax of a CSS comment.

Example

input.css:

/*! This comment will be removed! */
/* This comment will be kept! */
a {}

output.css:

/* This comment will be kept! */
a {}

Installation

postcss-optional-comments is freely available to download from github or install via NPM.

Install using NPM:

npm i --save-dev postcss-optional-comments

Usage

Gulp

Use with gulp-postcss module.

gulp.task('css', function () {
  var postcss          = require('gulp-postcss');
  var optionalComments = require('postcss-optional-comments');

  return gulp.src('./src/**/*.css')
    .pipe(postcss([ optionalComments ]))
    .pipe(gulp.dest('./dest'));
});

Todo

  • Support single line comments

Contributing

Feel free to submit a pull request!