Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
64 lines (56 loc) · 1.51 KB
/
Copy pathwebpack.config.js
File metadata and controls
64 lines (56 loc) · 1.51 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* WordPress dependencies
*/
const [
defaultScriptConfig,
defaultModuleConfig,
] = require( '@wordpress/scripts/config/webpack.config' );
/**
* External dependencies
*/
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const path = require( 'path' );
/**
* Define your script entrypoints here.
*
* Each entrypoint will be built into its own enqueuable asset.
*
* Blocks are handled separately via the `--package-manifest` flag in `@wordpress/scripts`
*/
const scriptEntries = {
'admin-ui': path.resolve( process.cwd(), 'src/admin/index.ts' ),
editor: path.resolve( process.cwd(), 'src/editor/index.tsx' ),
};
/**
* Define your Script Module entrypoints here.
*
* Each entrypoint will be built into its own enqueuable asset.
*
* Blocks are handled separately via the `--package-manifest` flag in `@wordpress/scripts`
*/
const scriptModuleEntries = {};
const scriptConfig = {
...defaultScriptConfig,
entry: {
// WordPress stores them in a function.
...defaultScriptConfig.entry(),
...scriptEntries,
},
plugins: [
// Include WP's plugin config.
...defaultScriptConfig.plugins,
// Removes the empty `.js` files generated by webpack but
// sets it after WP has generated its `*.asset.php` file.
new RemoveEmptyScriptsPlugin( {
stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
} ),
],
};
const moduleConfig = {
...defaultModuleConfig,
entry: {
...defaultModuleConfig.entry,
...scriptModuleEntries,
},
};
module.exports = [ scriptConfig, moduleConfig ];