-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
46 lines (42 loc) · 1.08 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
// WordPress webpack config.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
// Utilities.
const path = require( 'path' );
// React-jsx-runtime polyfill.
// @see https://github.com/WordPress/gutenberg/issues/62202
const reactJSXRuntimePolyfillConfig = {
entry: {
'react-jsx-runtime': {
import: 'react/jsx-runtime',
},
},
output: {
path: path.resolve( process.cwd(), 'dist/js/react-jsx-runtime' ), // Use separate directory to prevent files getting deleted by CleanWebpackPlugin
filename: 'react-jsx-runtime.js',
library: {
name: 'ReactJSXRuntime',
type: 'window',
},
},
externals: {
react: 'React',
},
};
const mainConfig = {
...defaultConfig,
...{
entry: {
editor: path.resolve( process.cwd(), 'src/js', 'editor.js' ),
},
output: {
path: path.resolve( process.cwd(), 'dist/js/main' ),
filename: '[name].js',
},
plugins: [
// Include WP's plugin config.
...defaultConfig.plugins,
],
},
};
// Add any new entry points by extending the webpack config.
module.exports = [ mainConfig, reactJSXRuntimePolyfillConfig ];