项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 Plugins" src="http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg">
  10. <a href="https://github.com/postcss/postcss">
  11. <img width="110" height="110" title="PostCSS" src="http://postcss.github.io/postcss/logo.svg" hspace="10">
  12. </a>
  13. <h1>Load Plugins</h1>
  14. </div>
  15. <h2 align="center">Install</h2>
  16. ```bash
  17. npm i -D postcss-load-plugins
  18. ```
  19. <h2 align="center">Usage</h2>
  20. ```
  21. npm i -S|-D postcss-plugin
  22. ```
  23. Install plugins and save them to your ***package.json*** dependencies/devDependencies.
  24. ### `package.json`
  25. Create **`postcss`** section in your projects **`package.json`**.
  26. ```
  27. App
  28. |– client
  29. |– public
  30. |
  31. |- package.json
  32. ```
  33. ```json
  34. {
  35. "postcss": {
  36. "plugins": {
  37. "postcss-plugin": {}
  38. }
  39. }
  40. }
  41. ```
  42. ### `.postcssrc`
  43. Create a **`.postcssrc`** file.
  44. ```
  45. App
  46. |– client
  47. |– public
  48. |
  49. |- (.postcssrc|.postcssrc.json|.postcssrc.yaml)
  50. |- package.json
  51. ```
  52. **`JSON`**
  53. ```json
  54. {
  55. "plugins": {
  56. "postcss-plugin": {}
  57. }
  58. }
  59. ```
  60. **`YAML`**
  61. ```yaml
  62. plugins:
  63. postcss-plugin: {}
  64. ```
  65. ### `postcss.config.js` or `.postcssrc.js`
  66. 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`**.
  67. ```
  68. App
  69. |– client
  70. |– public
  71. |
  72. |- (postcss.config.js|.postcssrc.js)
  73. |- package.json
  74. ```
  75. Plugins can be loaded in either using an `{Object}` or an `{Array}`.
  76. ##### `{Object}`
  77. ```js
  78. module.exports = (ctx) => ({
  79. plugins: {
  80. 'postcss-plugin': ctx.plugin
  81. }
  82. })
  83. ```
  84. ##### `{Array}`
  85. ```js
  86. module.exports = (ctx) => ({
  87. plugins: [
  88. require('postcss-plugin')(ctx.plugin)
  89. ]
  90. })
  91. ```
  92. <h2 align="center">Options</h2>
  93. Plugin **options** can take the following values.
  94. **`{}`: Plugin loads with defaults**
  95. ```js
  96. 'postcss-plugin': {} || null
  97. ```
  98. > :warning: `{}` must be an **empty** object
  99. **`{Object}`: Plugin loads with options**
  100. ```js
  101. 'postcss-plugin': { option: '', option: '' }
  102. ```
  103. **`false`: Plugin will not be loaded**
  104. ```js
  105. 'postcss-plugin': false
  106. ```
  107. ### Order
  108. Plugin **order** is determined by declaration in the plugins section.
  109. ```js
  110. {
  111. plugins: {
  112. 'postcss-plugin': {}, // plugins[0]
  113. 'postcss-plugin': {}, // plugins[1]
  114. 'postcss-plugin': {} // plugins[2]
  115. }
  116. }
  117. ```
  118. ### Context
  119. When using a function `(postcss.config.js)`, it is possible to pass context to `postcss-load-plugins`, which will be evaluated before loading your plugins. By default `ctx.env (process.env.NODE_ENV)` and `ctx.cwd (process.cwd())` are available.
  120. <h2 align="center">Examples</h2>
  121. **`postcss.config.js`**
  122. ```js
  123. module.exports = (ctx) => ({
  124. plugins: {
  125. postcss-import: {},
  126. postcss-modules: ctx.modules ? {} : false,
  127. cssnano: ctx.env === 'production' ? {} : false
  128. }
  129. })
  130. ```
  131. ### <img width="80" height="80" src="https://worldvectorlogo.com/logos/nodejs-icon.svg">
  132. ```js
  133. const { readFileSync } = require('fs')
  134. const postcss = require('postcss')
  135. const pluginsrc = require('postcss-load-plugins')
  136. const css = readFileSync('index.css', 'utf8')
  137. const ctx = { modules: true }
  138. pluginsrc(ctx).then((plugins) => {
  139. postcss(plugins)
  140. .process(css)
  141. .then((result) => console.log(result.css))
  142. })
  143. ```
  144. <h2 align="center">Maintainers</h2>
  145. <table>
  146. <tbody>
  147. <tr>
  148. <td align="center">
  149. <img width="150" height="150"
  150. src="https://github.com/michael-ciniawsky.png?v=3&s=150">
  151. <br>
  152. <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
  153. </td>
  154. <td align="center">
  155. <img width="150" height="150"
  156. src="https://github.com/ertrzyiks.png?v=3&s=150">
  157. <br>
  158. <a href="https://github.com/ertrzyiks">Mateusz Derks</a>
  159. </td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. <h2 align="center">Contributors</h2>
  164. <table>
  165. <tbody>
  166. <tr>
  167. <td align="center">
  168. <img width="150" height="150"
  169. src="https://github.com/Kovensky.png?v=3&s=150">
  170. <br>
  171. <a href="https://github.com/Kovensky">Diogo Franco</a>
  172. </td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. [npm]: https://img.shields.io/npm/v/postcss-load-plugins.svg
  177. [npm-url]: https://npmjs.com/package/postcss-load-plugins
  178. [node]: https://img.shields.io/node/v/postcss-load-plugins.svg
  179. [node-url]: https://nodejs.org/
  180. [deps]: https://david-dm.org/michael-ciniawsky/postcss-load-plugins.svg
  181. [deps-url]: https://david-dm.org/michael-ciniawsky/postcss-load-plugins
  182. [tests]: http://img.shields.io/travis/michael-ciniawsky/postcss-load-plugins.svg
  183. [tests-url]: https://travis-ci.org/michael-ciniawsky/postcss-load-plugins
  184. [cover]: https://coveralls.io/repos/github/michael-ciniawsky/postcss-load-plugins/badge.svg
  185. [cover-url]: https://coveralls.io/github/michael-ciniawsky/postcss-load-plugins
  186. [style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
  187. [style-url]: http://standardjs.com/
  188. [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg
  189. [chat-url]: https://gitter.im/postcss/postcss