forked from woocommerce/woocommerce-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
124 lines (116 loc) · 2.61 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* Internal dependencies
*/
const FallbackModuleDirectoryPlugin = require( './bin/fallback-module-directory-webpack-plugin' );
const { NODE_ENV, FORCE_MAP, getAlias } = require( './bin/webpack-helpers.js' );
const {
getCoreConfig,
getMainConfig,
getFrontConfig,
getPaymentsConfig,
} = require( './bin/webpack-configs.js' );
// Only options shared between all configs should be defined here.
const sharedConfig = {
mode: NODE_ENV,
performance: {
hints: false,
},
stats: {
all: false,
assets: true,
builtAt: true,
colors: true,
errors: true,
hash: true,
timings: true,
},
watchOptions: {
ignored: /node_modules/,
},
devtool: NODE_ENV === 'development' || FORCE_MAP ? 'source-map' : false,
};
// Core config for shared libraries.
const CoreConfig = {
...sharedConfig,
...getCoreConfig( { alias: getAlias() } ),
};
// Main Blocks config for registering Blocks and for the Editor.
const MainConfig = {
...sharedConfig,
...getMainConfig( {
alias: getAlias(),
// This file is already imported by the All Products dependencies, so we can safely exclude
// it from the default build. It's still needed in the legacy build because it doesn't
// include the All Products block.
exclude: [ 'product-list-style' ],
} ),
};
// Frontend config for scripts used in the store itself.
const FrontendConfig = {
...sharedConfig,
...getFrontConfig( { alias: getAlias() } ),
};
/**
* This is a temporary config for building the payment methods integration script until it can be
* moved into the payment extension(s).
*/
const PaymentsConfig = {
...sharedConfig,
...getPaymentsConfig( { alias: getAlias() } ),
};
/**
* Legacy Configs are for builds targeting < WP5.3 and handle backwards compatibility and disabling
* unsupported features.
*/
const LegacyMainConfig = {
...sharedConfig,
...getMainConfig( {
fileSuffix: 'legacy',
resolvePlugins: [
new FallbackModuleDirectoryPlugin(
'/legacy/',
'/',
getAlias( { pathPart: 'legacy' } )
),
],
exclude: [
'all-products',
'price-filter',
'attribute-filter',
'active-filters',
'checkout',
'cart',
'single-product',
],
} ),
};
const LegacyFrontendConfig = {
...sharedConfig,
...getFrontConfig( {
fileSuffix: 'legacy',
resolvePlugins: [
new FallbackModuleDirectoryPlugin(
'/legacy/',
'/',
getAlias( { pathPart: 'legacy' } )
),
],
exclude: [
'all-products',
'price-filter',
'attribute-filter',
'active-filters',
'checkout',
'cart',
'single-product',
],
} ),
};
module.exports = [
CoreConfig,
MainConfig,
FrontendConfig,
PaymentsConfig,
LegacyMainConfig,
LegacyFrontendConfig,
];