PostCSS color-mod() Function runs in all Node environments, with special instructions for:
Node | PostCSS CLI | Webpack | Create React App | Gulp | Grunt |
---|
Add PostCSS color-mod() Function to your project:
npm install postcss postcss-color-mod-function --save-dev
Use PostCSS color-mod() Function to process your CSS:
const postcssColorMod = require('postcss-color-mod-function');
postcssColorMod.process(YOUR_CSS /*, processOptions, pluginOptions */);
Or use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssColorMod = require('postcss-color-mod-function');
postcss([
postcssColorMod(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
Add PostCSS CLI to your project:
npm install postcss-cli --save-dev
Use PostCSS color-mod() Function in your postcss.config.js
configuration file:
const postcssColorMod = require('postcss-color-mod-function');
module.exports = {
plugins: [
postcssColorMod(/* pluginOptions */)
]
}
Add PostCSS Loader to your project:
npm install postcss-loader --save-dev
Use PostCSS color-mod() Function in your Webpack configuration:
const postcssColorMod = require('postcss-color-mod-function');
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: {
ident: 'postcss',
plugins: () => [
postcssColorMod(/* pluginOptions */)
]
} }
]
}
]
}
}
Add React App Rewired and React App Rewire PostCSS to your project:
npm install react-app-rewired react-app-rewire-postcss --save-dev
Use React App Rewire PostCSS and PostCSS color-mod() Function in your
config-overrides.js
file:
const reactAppRewirePostcss = require('react-app-rewire-postcss');
const postcssColorMod = require('postcss-color-mod-function');
module.exports = config => reactAppRewirePostcss(config, {
plugins: () => [
postcssColorMod(/* pluginOptions */)
]
});
Add Gulp PostCSS to your project:
npm install gulp-postcss --save-dev
Use PostCSS color-mod() Function in your Gulpfile:
const postcss = require('gulp-postcss');
const postcssColorMod = require('postcss-color-mod-function');
gulp.task('css', () => gulp.src('./src/*.css').pipe(
postcss([
postcssColorMod(/* pluginOptions */)
])
).pipe(
gulp.dest('.')
));
Add Grunt PostCSS to your project:
npm install grunt-postcss --save-dev
Use PostCSS color-mod() Function in your Gruntfile:
const postcssColorMod = require('postcss-color-mod-function');
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
postcssColorMod(/* pluginOptions */)
]
},
dist: {
src: '*.css'
}
}
});