-
Notifications
You must be signed in to change notification settings - Fork 30
/
webpack.config.js
35 lines (32 loc) · 1001 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
/**
* 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.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-scripts/#provide-your-own-webpack-config
*/
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' ] ),
],
};