-
Notifications
You must be signed in to change notification settings - Fork 4k
/
webpack.config.js
50 lines (46 loc) · 934 Bytes
/
webpack.config.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
43
44
45
46
47
48
49
50
/**
* External dependencies
*/
const path = require( 'path' );
/**
* WordPress dependencies
*/
const postcssPlugins = require( '@wordpress/postcss-plugins-preset' );
const scssLoaders = ( { isLazy } ) => [
{
loader: 'style-loader',
options: { injectType: isLazy ? 'lazyStyleTag' : 'styleTag' },
},
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
ident: 'postcss',
plugins: postcssPlugins,
},
},
},
'sass-loader',
];
module.exports = ( { config } ) => {
config.module.rules.push(
{
test: /\/stories\/.+\.js$/,
loader: require.resolve( '@storybook/source-loader' ),
enforce: 'pre',
},
{
test: /\.scss$/,
exclude: /\.lazy\.scss$/,
use: scssLoaders( { isLazy: false } ),
include: path.resolve( __dirname ),
},
{
test: /\.lazy\.scss$/,
use: scssLoaders( { isLazy: true } ),
include: path.resolve( __dirname ),
}
);
return config;
};