postcss-load-config
Load Config
Install
Usage
Install all required postcss plugins and save them to your package.json dependencies
/devDependencies
Then create a postcss config file by choosing one of the following formats
package.json
package.json
Create a postcss
section in your projects package.json
.postcssrc
.postcssrc
Create a .postcssrc
file in JSON or YAML format
ℹ️ It's recommended to use an extension (e.g
.postcssrc.json
or.postcssrc.yml
) instead of.postcssrc
.postcssrc.json
.postcssrc.yml
.postcssrc.js
or postcss.config.js
.postcssrc.js
or postcss.config.js
You may need some logic within your config. In this case create JS file named .postcssrc.js
or postcss.config.js
You can export the config as an {Object}
.postcssrc.js
Or export a {Function}
that returns the config (more about the ctx
param below)
.postcssrc.js
Plugins can be loaded either using an {Object}
or an {Array}
{Object}
.postcssrc.js
{Array}
.postcssrc.js
⚠️ When using an
{Array}
, make sure torequire()
each plugin
Options
Name | Type | Default | Description |
---|---|---|---|
|
| Destination File Path | |
|
| Enable/Disable Source Maps | |
|
| Source File Path | |
|
| Custom PostCSS Parser | |
|
| Custom PostCSS Syntax | |
|
| Custom PostCSS Stringifier |
parser
parser
.postcssrc.js
syntax
syntax
.postcssrc.js
stringifier
stringifier
.postcssrc.js
.postcssrc.js
⚠️ In most cases
options.from
&&options.to
are set by the third-party which integrates this package (CLI, gulp, webpack). It's unlikely one needs to set/useoptions.from
&&options.to
within a config file. Unless you're a third-party plugin author using this module and its Node API directly dont't setoptions.from
&&options.to
yourself
to
to
from
from
Plugins
{} || null
{} || null
The plugin will be loaded with defaults
.postcssrc.js
⚠️
{}
must be an empty{Object}
literal
{Object}
{Object}
The plugin will be loaded with given options
.postcssrc.js
false
false
The plugin will not be loaded
.postcssrc.js
Ordering
Ordering
Plugin execution order is determined by declaration in the plugins section (top-down)
Context
When using a {Function}
(postcss.config.js
or .postcssrc.js
), it's possible to pass context to postcss-load-config
, which will be evaluated while loading your config. By default ctx.env (process.env.NODE_ENV)
and ctx.cwd (process.cwd())
are available on the ctx
{Object}
ℹ️ Most third-party integrations add additional properties to the
ctx
(e.gpostcss-loader
). Check the specific module's README for more information about what is available on the respectivectx
Examples
postcss.config.js
webpack.config.js
Maintainers
Contributors
Last updated