-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
36 lines (33 loc) · 935 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
/**
* Custom webpack config for multiple blocks.
*/
const { basename, dirname, parse } = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
optimization: {
...( defaultConfig?.optimization || {} ),
splitChunks: {
...( defaultConfig?.optimization?.splitChunks || {} ),
cacheGroups: {
...( defaultConfig?.optimization?.splitChunks?.cacheGroups ||
{} ),
// Output individual CSS files with original filename.
style: {
type: 'css/mini-extract',
test: /\.(sc|sa|c)ss$/,
chunks: 'all',
enforce: true,
name( module, chunks, cacheGroupKey ) {
const chunkName = dirname( chunks[ 0 ].name );
const fileName = parse( module._identifier ).name;
return `${ dirname( chunkName ) }/${ basename(
chunkName
) }/${ fileName }`;
},
},
default: false,
},
},
},
};