-
Notifications
You must be signed in to change notification settings - Fork 199
/
webpack.config.js
67 lines (66 loc) · 1.9 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const path = require( 'path' );
const webpack = require( 'webpack' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const DependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
module.exports = {
...defaultConfig,
devtool:
process.env.NODE_ENV === 'production'
? 'hidden-source-map'
: defaultConfig.devtool,
optimization: {
...defaultConfig.optimization,
minimizer: [
...defaultConfig.optimization.minimizer.map( ( plugin ) => {
if ( plugin.constructor.name === 'TerserPlugin' ) {
// wp-scripts does not allow to override the Terser minimizer sourceMap option, without this
// `devtool: 'hidden-source-map'` is not generated for js files.
plugin.options.sourceMap = true;
}
return plugin;
} ),
],
splitChunks: undefined,
},
plugins: [
...defaultConfig.plugins.filter(
( plugin ) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new DependencyExtractionWebpackPlugin( {
injectPolyfill: true,
} ),
new webpack.DefinePlugin( {
__PAYMENT_METHOD_FEES_ENABLED: JSON.stringify(
process.env.PAYMENT_METHOD_FEES_ENABLED === 'true'
),
} ),
],
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
],
},
resolve: {
extensions: [ '.json', '.js', '.jsx', '.mjs' ],
modules: [ path.join( __dirname, 'client' ), 'node_modules' ],
alias: {
wcstripe: path.resolve( __dirname, 'client' ),
},
},
entry: {
index: './client/blocks/index.js',
payment_requests_settings:
'./client/entrypoints/payment-request-settings/index.js',
upe_classic: './client/classic/upe/index.js',
upe_blocks: './client/blocks/upe/index.js',
upe_settings: './client/settings/index.js',
payment_gateways: './client/entrypoints/payment-gateways/index.js',
},
};