You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition each imported file is linted with [postcss-bem-linter](https://github.com/postcss/postcss-bem-linter) and minification is provided by [cssnano](http://cssnano.co/).
18
+
Each imported file is linted with [postcss-bem-linter](https://github.com/postcss/postcss-bem-linter) and minification is provided by [cssnano](http://cssnano.co/). Additional plugins can be added via the configuration options.
19
19
20
20
## Installation
21
21
@@ -64,7 +64,74 @@ Examples:
64
64
$ cat input.css | suitcss | grep background-color
65
65
```
66
66
67
-
### Configuration
67
+
### Node.js
68
+
69
+
Returns a [PostCSS promise](https://github.com/postcss/postcss/blob/master/docs/api.md#lazyresult-class)
70
+
71
+
```js
72
+
var preprocessor =require('suitcss-preprocessor');
73
+
var fs =require('fs');
74
+
75
+
var css =fs.readFileSync('src/components/index.css', 'utf8');
76
+
77
+
preprocessor(css, {
78
+
root:'path/to/css',
79
+
minify:true,
80
+
}).then(function(result) {
81
+
fs.writeFileSync('build/bundle.css', result.css);
82
+
});
83
+
```
84
+
85
+
#### Options
86
+
87
+
##### `root`
88
+
89
+
* Type: `String`
90
+
* Default: `process.cwd()`
91
+
92
+
Where to resolve imports from. Passed to [`postcss-import`](https://github.com/postcss/postcss-import/blob/master/README.md#root).
93
+
94
+
##### `minify`
95
+
96
+
* Type: `Boolean`
97
+
* Default: `false`
98
+
99
+
If set to `true` then the output is minified by [`cssnano`](http://cssnano.co/).
100
+
101
+
##### `beforeLint`
102
+
103
+
* Type: `Function`
104
+
* Default: `false`
105
+
106
+
Called with the imported CSS before it's passed to `postcss-bem-linter`. This allows you to transform the CSS first and it must return the css string.
107
+
108
+
Third paramater is the options object containing any PostCSS configuration you may need.
Creating a configuration file allows options to be passed to the individual PostCSS plugins. It can be passed to the `suitcss` CLI via the `-c` flag and can be either JavaScript or JSON
70
137
@@ -90,7 +157,7 @@ Options are merged recursively with the defaults. For example, adding new plugin
90
157
91
158
By default the preprocessor uses all necessary plugins to build SUIT components. However additional plugins can be installed into a project and then added to the `use` array.
92
159
93
-
This **will not** work with the preprocessor installed globally. Instead rely on the convenience of `npm run <script>`
160
+
**Note**: This will not work with the preprocessor installed globally. Instead rely on the convenience of `npm run <script>`
94
161
95
162
```js
96
163
module.exports= {
@@ -154,29 +221,6 @@ var result = [
154
221
];
155
222
```
156
223
157
-
### Node.js
158
-
159
-
Returns a [PostCSS promise](https://github.com/postcss/postcss/blob/master/docs/api.md#lazyresult-class)
160
-
161
-
```js
162
-
var preprocessor =require('suitcss-preprocessor');
163
-
var fs =require('fs');
164
-
165
-
var css =fs.readFileSync('src/components/index.css', 'utf8');
0 commit comments