forked from woocommerce/google-listings-and-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-development.config.js
48 lines (44 loc) · 1.35 KB
/
webpack-development.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
/**
* This file was copied from the following and has some adjustments for fitting with this repo.
* https://github.com/WordPress/gutenberg/blob/%40wordpress/scripts%4022.1.0/tools/webpack/development.js
*
* More details of how to enable Fast Refresh in WordPress plugin development can be found in this PR:
* https://github.com/WordPress/gutenberg/pull/28273
*/
const path = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
const sharedConfig = {
mode: 'development',
target: defaultConfig.target,
output: {
filename: '[name].js',
path: path.join( __dirname, 'js/build-dev' ),
},
};
const reactRefreshEntryConfig = {
...sharedConfig,
entry: {
'react-refresh-entry':
'@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js',
},
plugins: [ new WooCommerceDependencyExtractionWebpackPlugin() ],
};
const reactRefreshRuntimeConfig = {
...sharedConfig,
entry: {
'react-refresh-runtime': {
import: 'react-refresh/runtime.js',
library: {
name: 'ReactRefreshRuntime',
type: 'window',
},
},
},
plugins: [
new WooCommerceDependencyExtractionWebpackPlugin( {
useDefaults: false,
} ),
],
};
module.exports = [ reactRefreshEntryConfig, reactRefreshRuntimeConfig ];