-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
40 lines (36 loc) · 1.34 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
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
const requestToExternal = ( request ) => {
// Bundle these packages & components so we can use the latest, independent of WordPress version.
// Without bundling these specific recent versions, components like LandingPageApp don't render correctly.
const bundled = [ '@wordpress/components', '@wordpress/compose' ];
if ( bundled.includes( request ) ) {
return false;
}
};
// Replace the default DependencyExtractionWebpackPlugin with the Woo version
// and override to bundle specific newer packages (see requestToExternal above).
const ourPlugins = [
...defaultConfig.plugins.filter(
( plugin ) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new WooCommerceDependencyExtractionWebpackPlugin( {
injectPolyfill: true, // TBD Confirm this is needed for Pinterest.
requestToExternal,
} ),
];
const webpackConfig = {
...defaultConfig,
plugins: ourPlugins,
entry: {
'setup-guide': __dirname + '/assets/source/setup-guide/index.js',
'product-attributes':
__dirname + '/assets/source/product-attributes/index.js',
},
output: {
filename: '[name].js',
path: __dirname + '/assets/build',
},
};
module.exports = webpackConfig;