Package Exports
- postcss-load-options
- postcss-load-options/lib/loadOptions.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-load-options) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Load Options
Autoload Options for PostCSS
Install
npm i -D postcss-load-options
Options
package.json
{
"dependencies": {
"sugarss": "^0.1.4"
},
"postcss": {
"parser": "sugarss",
"map": false,
"from": "src/app.sss",
"to": "dest/app.css"
}
}
.postcssrc
{
"parser": "sugarss",
"map": false,
"from": "src/app.sss",
"to": "dest/app.css"
}
postcss.config.js
module.exports = (ctx) => {
parser: ctx.parser || 'sugarss',
map: ctx.env === 'dev' ? ctx.map || 'false',
from: ctx.from || 'src/app.sss',
to: ctx.to || 'dest/app.css'
}
Usage
const { readFileSync } = require('fs')
const postcss = require('postcss')
const optionsrc = require('postcss-load-options')()
const css = readFileSync('index.css', 'utf8')
optionsrc.then((options) => {
postcss([])
.process(css, options)
.then(result => console.log(result.css))
}))
Context
const { readFileSync } = require('fs')
const postcss = require('postcss')
const optionsrc = require('postcss-load-options')
const css = readFileSync('index.css', 'utf8')
const ctx = {
env: 'dev',
map: 'inline'
}
optionsrc(ctx).then((options) => {
postcss([])
.process(css, options)
.then(result => console.log(result.css))
}))
Maintainers
Michael Ciniawsky |