-
Notifications
You must be signed in to change notification settings - Fork 94
/
index.js
40 lines (37 loc) · 942 Bytes
/
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
/**
* SASS webpack block.
*
* @see https://github.com/jtangelder/sass-loader
*/
module.exports = sass
/**
* @param {object} [options] See https://github.com/sass/node-sass#options
* @param {string[]} [options.sassOptions.includePaths]
* @param {bool} [options.sassOptions.indentedSyntax]
* @param {string} [options.sassOptions.outputStyle]
* @param {bool} [options.sourceMap]
* @return {Function}
*/
function sass(options = {}) {
return (context, util) => {
if (!context.match) {
throw Error(
'You cannot use the sass() block outside a match() block. You also need to use the css() block on sass files.'
)
}
return util.addLoader(
Object.assign(
{
test: /\.(sass|scss)$/,
use: [
{
loader: 'sass-loader',
options
}
]
},
context.match
)
)
}
}