-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathindex.js
42 lines (37 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* PostCSS webpack block.
*
* @see https://github.com/postcss/postcss-loader
*/
module.exports = postcss
/**
* @param {object} [options] https://github.com/postcss/postcss-loader#options
* @param {string} [options.parser] Package name of custom PostCSS parser to use.
* @param {string} [options.stringifier] Package name of custom PostCSS stringifier to use.
* @param {string} [options.syntax] Package name of custom PostCSS parser/stringifier to use.
* @param {PostCSSPlugin[]} [options.plugins] PostCSS plugins, will read `postcss.config.js` file if not supplied.
* @return {Function}
*/
function postcss(options = {}) {
if (Array.isArray(options)) {
throw Error(
'Passing PostCSS plugins as a first argument is not supported anymore, use options.plugins instead'
)
}
return (context, util) => prevConfig => {
const ruleDef = Object.assign(
{
test: /\.css$/,
use: [
{
loader: 'postcss-loader',
options
}
]
},
context.match
)
let nextConfig = util.addLoader(ruleDef)(prevConfig)
return nextConfig
}
}