|
| 1 | +# postcss-import-ext-glob [![Build Status][travis badge]][travis link] [![Coverage Status][coveralls badge]][coveralls link] |
| 2 | + |
| 3 | +A [PostCSS][postcss] plugin to extend [postcss-import][postcss-import] path |
| 4 | +resolver to allow [glob][glob ref] usage as path. |
| 5 | + |
| 6 | +You must use this plugin along with [postcss-import][postcss-import], place this |
| 7 | +plugin **before** `postcss-import`. |
| 8 | + |
| 9 | +```css |
| 10 | +@import-glob "components/**/*.css"; |
| 11 | +``` |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```console |
| 16 | +$ npm install postcss-import-ext-glob |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +```js |
| 22 | +// Postcss plugins |
| 23 | +postcss([ |
| 24 | + require('postcss-import-ext-glob'), |
| 25 | + require('postcss-import') |
| 26 | +]); |
| 27 | +``` |
| 28 | + |
| 29 | +Check out [PostCSS](https://github.com/postcss/postcss) docs for the complete |
| 30 | +installation. |
| 31 | + |
| 32 | +### Example |
| 33 | + |
| 34 | +This plugin transform this: |
| 35 | + |
| 36 | +```css |
| 37 | +@import-glob "components/**/*.css"; |
| 38 | +``` |
| 39 | + |
| 40 | +into this: |
| 41 | + |
| 42 | +```css |
| 43 | +@import "components/form/input.css"; |
| 44 | +@import "components/form/submit.css"; |
| 45 | +/* etc */ |
| 46 | +``` |
| 47 | + |
| 48 | +Thereby, the plugin `postcss-import` can now import each file. |
| 49 | + |
| 50 | +You can pass multiple globs in one: |
| 51 | + |
| 52 | +```css |
| 53 | +@import-glob "helpers/**/*.css", "components/**/*.css"; |
| 54 | +``` |
| 55 | + |
| 56 | +## Options |
| 57 | + |
| 58 | +You can pass a `sort` option to this plugin with a value of "asc" or "desc": |
| 59 | + |
| 60 | +```js |
| 61 | +// Postcss plugins |
| 62 | +postcss([ |
| 63 | + require('postcss-import-ext-glob')({ |
| 64 | + sort: 'desc' |
| 65 | + }), |
| 66 | + require('postcss-import') |
| 67 | +]); |
| 68 | +``` |
| 69 | + |
| 70 | +The sort order is by default ascending. |
| 71 | + |
| 72 | +## Related |
| 73 | + |
| 74 | +- [postcss-import][postcss-import] - PostCSS plugin to inline @import rules |
| 75 | +content |
| 76 | +- [fast-glob][fast-glob] - Module used for getting glob entries |
| 77 | +- [fast-sort][fast-sort] - Module used for sorting glob entries |
| 78 | + |
| 79 | +## License |
| 80 | + |
| 81 | +This project is licensed under the [MIT license](LICENSE). |
| 82 | + |
| 83 | +[travis badge]: https://travis-ci.org/dimitrinicolas/postcss-import-ext-glob.svg?branch=master |
| 84 | +[travis link]: https://travis-ci.org/dimitrinicolas/postcss-import-ext-glob |
| 85 | +[coveralls badge]: https://coveralls.io/repos/github/dimitrinicolas/postcss-import-ext-glob/badge.svg?branch=master |
| 86 | +[coveralls link]: https://coveralls.io/github/dimitrinicolas/postcss-import-ext-glob?branch=master |
| 87 | + |
| 88 | +[postcss]: https://github.com/postcss/postcss |
| 89 | +[postcss-import]: https://github.com/postcss/postcss-import |
| 90 | +[fast-glob]: https://www.npmjs.com/package/fast-glob |
| 91 | +[fast-sort]: https://www.npmjs.com/package/fast-sort |
| 92 | + |
| 93 | +[glob ref]: https://en.wikipedia.org/wiki/Glob_(programming) |
0 commit comments