Load Options
Install
npm i -D postcss-load-options
Usage
package.json
Create postcss
section in your projects package.json
.
App
|– client
|– public
|
|- package.json
.postcssrc
Create a .postcssrc
file.
App
|– client
|– public
|
|- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
|- package.json
JSON
YAML
parser: sugarssmap: falsefrom: "/path/to/src.sss"to: "/path/to/dest.css"
postcss.config.js
or .postcssrc.js
You may need some JavaScript logic to generate your config. For this case you can use a file named postcss.config.js
or .postcssrc.js
.
App
|– client
|– public
|
|- (postcss.config.js|.postcssrc.js)
|- package.json
module { return parser: ctxsugar ? 'sugarss' : false map: ctxenv === 'development' ? ctxmap || false from: 'path/to/src/file.css' to: 'path/to/dest/file.css' }
Options
parser
:
'parser': 'sugarss'
syntax
:
'syntax': 'postcss-scss'
stringifier
:
'stringifier': 'midas'
'map': 'inline'
from
:
from: 'path/to/dest/file.css'
to
:
to: 'path/to/dest/file.css'
Context
When using a function (postcss.config.js)
, it is possible to pass context to postcss-load-options
, which will be evaluated before loading your options. By default ctx.env (process.env.NODE_ENV)
and ctx.cwd (process.cwd())
are available.
Example
const readFileSync = const postcss = const optionsrc = const sss = const ctx = sugar: true map: 'inline' )
Maintainers
Michael Ciniawsky |