Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-browser-comments-next

radiosilence38CC0-1.08.0.1

Keep only the CSS you need based on comments and your browserslist

postcss, css, postcss-plugin, browserslists, browserlists, browsers, lists, support, caniuse, target

readme

Forked from https://github.com/csstools/postcss-browser-comments

Packages has been forked to use devpeerapong's PostCSS 8 compatibility updates.

PostCSS Browser Comments Next PostCSS

NPM Version Build Status Support Chat

[PostCSS Browser Comments Next] lets you keep only the CSS you need based on comments and your browserslist.

/**
 * Prevent adjustments of font size after orientation changes in IE and iOS.
 */

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

The comment and rule above would be removed with the following browserslist:

last 2 chrome versions

The rule below would be more carefully altered:

/**
 * 1. Add the correct box sizing in Firefox.
 * 2. Show the overflow in Edge and IE.
 */

hr {
  box-sizing: content-box; /* 1 */
  height: 0; /* 1 */
  overflow: visible; /* 2 */
}

/* with a `last 2 firefox versions` browserslist becomes */

/**
 * 1. Add the correct box sizing in Firefox.
 * 2. Show the overflow in Edge and IE.
 */

hr {
  box-sizing: content-box; /* 1 */
  height: 0; /* 1 */
}

PostCSS Browser Comments can remove rules based upon the comment above them, or it can remove declarations using numbered comments that reference the rule above them. In the later case, when all of the numbered comments are removed, then the entire rule and comment are also removed.

Usage

Add PostCSS Browser Comments to your project:

npm install postcss postcss-browser-comments --save-dev

Use PostCSS Browser Comments to process your CSS:

const postcssBrowserComments = require('postcss-browser-comments');

postcssBrowserComments.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssBrowserComments = require('postcss-browser-comments');

postcss([
  postcssBrowserComments(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Browser Comments runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

browsers

The browsers option overrides of the project’s browserslist.

postcssBrowserComments({
  browsers: 'last 2 versions'
});

changelog

Changes to PostCSS Browser Comments

3.0.0 (May 24, 2019)

  • Updated: Node 8+ compatibility (major)

2.0.0 (September 6, 2018)

  • Update to PostCSS 7.0.2 (major)
  • Update to browserslist 4.1.1 (major)

1.0.0 (June 15, 2018)

  • Initial version