-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
38 lines (35 loc) · 1.02 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
/**
* Optional Webpack config.
*
* This config includes the `@wordpress/scripts` defaults, along with
* an entry path for `/src/frontend.js`. The frontend entry path is
* conditionally included and is not a requirement. It is safe to
* delete this file.
*
* @link https://developer.wordpress.org/block-editor/packages/packages-scripts/#provide-your-own-webpack-config
* @package WebDevStudios\BlockStarter
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const glob = require( 'glob' );
const IgnoreEmitPlugin = require( 'ignore-emit-webpack-plugin' );
const entry = { ...defaultConfig.entry };
/**
* If there is a `src/frontend.js`, set it as the entry file.
*/
const frontendScript = glob.sync( './src/frontend.js' );
if ( frontendScript.length ) {
entry.frontend = frontendScript;
}
/**
* Compile `src/frontend.js` using @wordpress/scripts.
*/
module.exports = {
...defaultConfig,
entry,
plugins: [
...defaultConfig.plugins,
new IgnoreEmitPlugin( [
'frontend.asset.php',
] ),
],
};