-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
50 lines (45 loc) · 1.15 KB
/
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
/**
* WordPress Dependencies.
*
* see, node_modules/@wordpress/scripts/config/webpack.config.js
*/
const glob = require('glob');
const path = require('path');
const defaultWordPressWebpackConfig = require( '@wordpress/scripts/config/webpack.config.js' );
// Append specifically to the default config, adding in the webpack import glob loader config.
defaultWordPressWebpackConfig.module.rules = [
{
test: /\.js$/,
use: 'webpack-import-glob-loader'
},
{
test: /\.scss$/,
use: 'webpack-import-glob-loader'
},
...defaultWordPressWebpackConfig.module.rules,
];
/**
* This determines if the built blocks are combined into single asset files, or multiple asset files,
* being one set of asset files per block.
*
* TODO, s
*
* @type {boolean}
*/
const multipleEntryPoint = true;
let entry = {};
if ( multipleEntryPoint ) {
entry = glob.sync( './blocks/*' )
.reduce( function( obj, el ) {
obj[ path.parse( el ).name ] = el;
return obj
}, {} );
} else {
// Use the default entry point.
entry = defaultWordPressWebpackConfig.entry();
}
module.exports = {
...defaultWordPressWebpackConfig,
// Add any overrides to the default here.
entry,
}