npm install @csstools/postcss-base-plugin --save-dev
PostCSS Base Plugin lets you easily create new plugins following some CSS Specification.
.foo {
color: red;
}
.baz {
color: green;
}
/* becomes */
.foo {
color: blue;
}
.baz {
color: green;
}
Add PostCSS Base Plugin to your project:
npm install postcss @csstools/postcss-base-plugin --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssBasePlugin = require('@csstools/postcss-base-plugin');
postcss([
postcssBasePlugin(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
PostCSS Base Plugin runs in all Node environments, with special instructions for:
The preserve
option determines whether the original notation
is preserved. By default, it is not preserved.
postcssBasePlugin({ preserve: true })
.foo {
color: red;
}
.baz {
color: green;
}
/* becomes */
.foo {
color: blue;
color: red;
}
.baz {
color: green;
}