postcss-load-config
Last updated
Last updated
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
Create a postcss
section in your projects package.json
.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
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
parser
.postcssrc.js
syntax
.postcssrc.js
stringifier
.postcssrc.js
.postcssrc.js
to
from
{} || null
The plugin will be loaded with defaults
.postcssrc.js
{Object}
The plugin will be loaded with given options
.postcssrc.js
false
The plugin will not be loaded
.postcssrc.js
Ordering
Plugin execution order is determined by declaration in the plugins section (top-down)
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
postcss.config.js
webpack.config.js
When using an {Array}
, make sure to require()
each plugin
Name | Type | Default | Description |
---|---|---|---|
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/use options.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 set options.from
&& options.to
yourself
{}
must be an empty {Object}
literal
{String}
undefined
Destination File Path
{String|Object}
false
Enable/Disable Source Maps
{String}
undefined
Source File Path
{String|Function}
false
Custom PostCSS Parser
{String|Function}
false
Custom PostCSS Syntax
{String|Function}
false
Custom PostCSS Stringifier