npm install postcss-browser-comments --save-dev
PostCSS Browser Comments lets you keep only the CSS you need based on
comments and your browserslist.
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:
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
hr {
box-sizing: content-box;
height: 0;
}
Usage
Add PostCSS Browser Comments to your project:
npm install postcss postcss-browser-comments --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssBrowserComments = require('postcss-browser-comments');
postcss([
postcssBrowserComments()
]).process(YOUR_CSS );
Options
browsers
The browsers option overrides of the project’s browserslist.
postcssBrowserComments({ browsers: 'last 2 versions' })