postcssconfigjs
Postcssconfigjs refers to the JavaScript configuration file used by PostCSS, a tool that transforms CSS through a chain of plugins. The file tells PostCSS which plugins to run, and with what options, as part of a build or processing workflow. It is commonly named postcss.config.js and placed at the project root, but PostCSS can also load other variants or be configured via package.json.
PostCSS automatically searches for a config file at the project root. Alternatives include postcss.config.cjs for CommonJS
The typical export is an object with a plugins property, which can be an array of plugin
- module.exports = { plugins: [ require('autoprefixer'), require('cssnano') ] };
- module.exports = (ctx) => ({
plugins: [
].concat(ctx.env === 'production' ? [ require('cssnano')() ] : [])
});
Plugins are applied in the order specified, so the sequence can affect the outcome. Commonly used plugins