forked from woocommerce/woocommerce-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
159 lines (148 loc) · 3.27 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
* 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,
getStylingConfig,
} = 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(),
} ),
};
// Frontend config for scripts used in the store itself.
const FrontendConfig = {
...sharedConfig,
...getFrontConfig( { alias: getAlias() } ),
};
/**
* Config for building the payment methods integration scripts.
*/
const PaymentsConfig = {
...sharedConfig,
...getPaymentsConfig( { alias: getAlias() } ),
};
/**
* Config to generate the CSS files.
*/
const StylingConfig = {
...sharedConfig,
...getStylingConfig( { alias: getAlias() } ),
};
/**
* Legacy Configs are for builds targeting < WP5.3 and handle backwards compatibility and disabling
* unsupported features.
*
* Now that WordPress 5.5 is released, as of WooCommerce Blocks 3.2.0 we don't support WP <5.3,
* so these legacy builds are not used. Keeping the config so we can conveniently reinstate
* these builds as needed (hence eslint-disable).
*/
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',
],
} ),
};
const LegacyStylingConfig = {
...sharedConfig,
...getStylingConfig( {
fileSuffix: 'legacy',
exclude: [
'all-products',
'price-filter',
'attribute-filter',
'active-filters',
'checkout',
'cart',
'single-product',
],
} ),
};
/**
* Now that WordPress 5.5 is released, as of WooCommerce Blocks 3.2.0 we don't support WP <5.3,
* so the legacy builds are not used. Keeping the config so we can conveniently reinstate
* these builds as needed (hence eslint-disable).
*/
// eslint-disable-next-line no-unused-vars
const legacyConfigs = [
LegacyMainConfig,
LegacyFrontendConfig,
LegacyStylingConfig,
];
module.exports = [
CoreConfig,
MainConfig,
FrontendConfig,
PaymentsConfig,
StylingConfig,
];