2 [![node][node]][node-url]
3 [![deps][deps]][deps-url]
4 [![tests][tests]][tests-url]
5 [![coverage][cover]][cover-url]
6 [![code style][style]][style-url]
7 [![chat][chat]][chat-url]
10 <img width="100" height="100" title="Load Options"
11 src="https://michael-ciniawsky.github.io/postcss-load-options/logo.svg"
12 <a href="https://github.com/postcss/postcss">
13 <img width="110" height="110" title="PostCSS" src="http://postcss.github.io/postcss/logo.svg" hspace="10">
18 <h2 align="center">Install</h2>
21 npm i -D postcss-load-options
23 <h2 align="center">Usage</h2>
27 Create **`postcss`** section in your projects **`package.json`**.
45 "from": "path/to/src/file.css",
46 "to": "path/to/dest/file.css"
53 Create a **`.postcssrc`** file.
60 |- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
69 "from": "path/to/src/file.css",
70 "to": "path/to/dest/file.css"
78 from: "/path/to/src.sss"
79 to: "/path/to/dest.css"
82 ### `postcss.config.js` or `.postcssrc.js`
84 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`**.
91 |- (postcss.config.js|.postcssrc.js)
96 module.exports = (ctx) => {
98 parser: ctx.sugar ? 'sugarss' : false,
99 map: ctx.env === 'development' ? ctx.map || false,
100 from: 'path/to/src/file.css',
101 to: 'path/to/dest/file.css'
106 <h2 align="center">Options</h2>
117 'syntax': 'postcss-scss'
122 'stringifier': 'midas'
125 [**`map`**:](https://github.com/postcss/postcss/blob/master/docs/source-maps.md)
134 from: 'path/to/dest/file.css'
140 to: 'path/to/dest/file.css'
145 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.
147 <h2 align="center">Example</h2>
149 ### <img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg">
152 const { readFileSync } = require('fs')
154 const postcss = require('postcss')
155 const optionsrc = require('postcss-load-options')
157 const sss = readFileSync('index.sss', 'utf8')
159 const ctx = { sugar: true, map: 'inline' }
161 optionsrc(ctx).then((options) => {
163 .process(sss, options)
164 .then(({ css }) => console.log(css))
168 <h2 align="center">Maintainers</h2>
174 <img width="150 height="150"
175 src="https://avatars.githubusercontent.com/u/5419992?v=3&s=150">
177 <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
184 [npm]: https://img.shields.io/npm/v/postcss-load-options.svg
185 [npm-url]: https://npmjs.com/package/postcss-load-options
187 [node]: https://img.shields.io/node/v/postcss-load-options.svg
188 [node-url]: https://nodejs.org/
190 [deps]: https://david-dm.org/michael-ciniawsky/postcss-load-options.svg
191 [deps-url]: https://david-dm.org/michael-ciniawsky/postcss-load-options
193 [tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-options.svg
194 [tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-options
196 [cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-options/badge.svg
197 [cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-options
199 [style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
200 [style-url]: http://standardjs.com/
202 [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg
203 [chat-url]: https://gitter.im/postcss/postcss