项目原始demo,不改动
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. [![npm][npm]][npm-url]
  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]
  8. <div align="center">
  9. <img width="100" height="100" title="Load Options"
  10. src="https://michael-ciniawsky.github.io/postcss-load-options/logo.svg"
  11. <a href="https://github.com/postcss/postcss">
  12. <img width="110" height="110" title="PostCSS" src="http://postcss.github.io/postcss/logo.svg" hspace="10">
  13. </a>
  14. <h1>Load Options</h1>
  15. </div>
  16. <h2 align="center">Install</h2>
  17. ```bash
  18. npm i -D postcss-load-options
  19. ```
  20. <h2 align="center">Usage</h2>
  21. ### `package.json`
  22. Create **`postcss`** section in your projects **`package.json`**.
  23. ```
  24. App
  25. |– client
  26. |– public
  27. |
  28. |- package.json
  29. ```
  30. ```json
  31. {
  32. "dependencies": {
  33. "sugarss": "0.2.0"
  34. },
  35. "postcss": {
  36. "parser": "sugarss",
  37. "map": false,
  38. "from": "path/to/src/file.css",
  39. "to": "path/to/dest/file.css"
  40. }
  41. }
  42. ```
  43. ### `.postcssrc`
  44. Create a **`.postcssrc`** file.
  45. ```
  46. App
  47. |– client
  48. |– public
  49. |
  50. |- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
  51. |- package.json
  52. ```
  53. **`JSON`**
  54. ```json
  55. {
  56. "parser": "sugarss",
  57. "map": false,
  58. "from": "path/to/src/file.css",
  59. "to": "path/to/dest/file.css"
  60. }
  61. ```
  62. **`YAML`**
  63. ```yaml
  64. parser: sugarss
  65. map: false
  66. from: "/path/to/src.sss"
  67. to: "/path/to/dest.css"
  68. ```
  69. ### `postcss.config.js` or `.postcssrc.js`
  70. 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`**.
  71. ```
  72. App
  73. |– client
  74. |– public
  75. |
  76. |- (postcss.config.js|.postcssrc.js)
  77. |- package.json
  78. ```
  79. ```js
  80. module.exports = (ctx) => {
  81. return {
  82. parser: ctx.sugar ? 'sugarss' : false,
  83. map: ctx.env === 'development' ? ctx.map || false,
  84. from: 'path/to/src/file.css',
  85. to: 'path/to/dest/file.css'
  86. }
  87. }
  88. ```
  89. <h2 align="center">Options</h2>
  90. **`parser`**:
  91. ```js
  92. 'parser': 'sugarss'
  93. ```
  94. **`syntax`**:
  95. ```js
  96. 'syntax': 'postcss-scss'
  97. ```
  98. **`stringifier`**:
  99. ```js
  100. 'stringifier': 'midas'
  101. ```
  102. [**`map`**:](https://github.com/postcss/postcss/blob/master/docs/source-maps.md)
  103. ```js
  104. 'map': 'inline'
  105. ```
  106. **`from`**:
  107. ```js
  108. from: 'path/to/dest/file.css'
  109. ```
  110. **`to`**:
  111. ```js
  112. to: 'path/to/dest/file.css'
  113. ```
  114. ### Context
  115. 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.
  116. <h2 align="center">Example</h2>
  117. ### <img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg">
  118. ```js
  119. const { readFileSync } = require('fs')
  120. const postcss = require('postcss')
  121. const optionsrc = require('postcss-load-options')
  122. const sss = readFileSync('index.sss', 'utf8')
  123. const ctx = { sugar: true, map: 'inline' }
  124. optionsrc(ctx).then((options) => {
  125. postcss()
  126. .process(sss, options)
  127. .then(({ css }) => console.log(css))
  128. }))
  129. ```
  130. <h2 align="center">Maintainers</h2>
  131. <table>
  132. <tbody>
  133. <tr>
  134. <td align="center">
  135. <img width="150 height="150"
  136. src="https://avatars.githubusercontent.com/u/5419992?v=3&s=150">
  137. <br />
  138. <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
  139. </td>
  140. </tr>
  141. <tbody>
  142. </table>
  143. [npm]: https://img.shields.io/npm/v/postcss-load-options.svg
  144. [npm-url]: https://npmjs.com/package/postcss-load-options
  145. [node]: https://img.shields.io/node/v/postcss-load-options.svg
  146. [node-url]: https://nodejs.org/
  147. [deps]: https://david-dm.org/michael-ciniawsky/postcss-load-options.svg
  148. [deps-url]: https://david-dm.org/michael-ciniawsky/postcss-load-options
  149. [tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-options.svg
  150. [tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-options
  151. [cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-options/badge.svg
  152. [cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-options
  153. [style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
  154. [style-url]: http://standardjs.com/
  155. [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg
  156. [chat-url]: https://gitter.im/postcss/postcss