@pixolith/webpack-sw6-config 12.0.3 → 12.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/config.js +16 -0
- package/src/index.js +15 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixolith/webpack-sw6-config",
|
|
3
3
|
"public": true,
|
|
4
|
-
"version": "12.0.
|
|
4
|
+
"version": "12.0.4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"scripts": {},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/pixolith/webpack-plugins/issues"
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/pixolith/webpack-plugins/tree/master/packages/webpack-hook-plugin/#readme",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "fb56cf1e8eb854872b9576456bdb1fbe7c5343f4",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/cli": "7.25.9",
|
|
27
27
|
"@babel/core": "^7.26.0",
|
package/src/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Path = require('path');
|
|
4
|
+
const Os = require('os');
|
|
4
5
|
|
|
5
6
|
const config = {
|
|
6
7
|
isProd: process.env.NODE_ENV === 'production',
|
|
@@ -83,6 +84,21 @@ if (pickedTheme && config.themeNames.indexOf(pickedTheme) === -1) {
|
|
|
83
84
|
// themeNames stays as the full list (used for _global_resources exclusion)
|
|
84
85
|
config.buildThemes = pickedTheme ? [pickedTheme] : config.themeNames;
|
|
85
86
|
|
|
87
|
+
// buildParallelism: how many per-theme compilers webpack's MultiCompiler runs
|
|
88
|
+
// concurrently. Default is webpack's `Infinity` (all themes at once) which is
|
|
89
|
+
// extremely memory-hungry with many themes. We cap it to a conservative,
|
|
90
|
+
// CPU-aware value. Override with BUILD_PARALLELISM=<n> (e.g. on big CI boxes).
|
|
91
|
+
// Peak memory ≈ buildParallelism × (memory of one theme compiler).
|
|
92
|
+
config.buildParallelism = (() => {
|
|
93
|
+
let raw = parseInt(process.env.BUILD_PARALLELISM, 10);
|
|
94
|
+
let value =
|
|
95
|
+
Number.isInteger(raw) && raw > 0
|
|
96
|
+
? raw
|
|
97
|
+
: Math.max(2, Math.floor(Os.cpus().length / 4));
|
|
98
|
+
// Never exceed the number of themes actually being built.
|
|
99
|
+
return Math.max(1, Math.min(value, config.buildThemes.length || 1));
|
|
100
|
+
})();
|
|
101
|
+
|
|
86
102
|
const pxEntryPath =
|
|
87
103
|
process.env.PX_ENTRY_PATH ||
|
|
88
104
|
(process.env.SHOPWARE_MODE === 'storefront'
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ const setup = () => {
|
|
|
35
35
|
shopwareMode: config.shopwareMode,
|
|
36
36
|
assetUrl: config.assetUrl,
|
|
37
37
|
themeNames: config.themeNames.join(', ') + (config.buildThemes.length < config.themeNames.length ? ' (building: ' + config.buildThemes.join(', ') + ')' : ''),
|
|
38
|
+
parallelism: config.buildParallelism + ' / ' + config.buildThemes.length + ' themes',
|
|
38
39
|
version: pkg.version,
|
|
39
40
|
});
|
|
40
41
|
}
|
|
@@ -125,7 +126,7 @@ const getResourcesPaths = (themeName, options) => {
|
|
|
125
126
|
const createThemeConfigs = (options) => {
|
|
126
127
|
setup();
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
let themeConfigs = config.buildThemes.map((themeName, index) => {
|
|
129
130
|
let resourcesPaths = getResourcesPaths(themeName, options);
|
|
130
131
|
let themeSlug = ChangeCase.kebabCase(themeName);
|
|
131
132
|
let themeOptions = {
|
|
@@ -157,6 +158,12 @@ const createThemeConfigs = (options) => {
|
|
|
157
158
|
|
|
158
159
|
return merged;
|
|
159
160
|
});
|
|
161
|
+
|
|
162
|
+
// Limit how many theme compilers run concurrently (webpack MultiCompiler).
|
|
163
|
+
// Without this webpack runs all of them in parallel in a single process.
|
|
164
|
+
themeConfigs.parallelism = config.buildParallelism;
|
|
165
|
+
|
|
166
|
+
return themeConfigs;
|
|
160
167
|
};
|
|
161
168
|
|
|
162
169
|
const setupAdministration = () => {
|
|
@@ -181,6 +188,7 @@ const setupAdministration = () => {
|
|
|
181
188
|
shopwareMode: config.shopwareMode,
|
|
182
189
|
assetUrl: config.assetUrl,
|
|
183
190
|
themeNames: config.themeNames.join(', ') + (config.buildThemes.length < config.themeNames.length ? ' (building: ' + config.buildThemes.join(', ') + ')' : ''),
|
|
191
|
+
parallelism: config.buildParallelism + ' / ' + config.buildThemes.length + ' themes',
|
|
184
192
|
version: pkg.version,
|
|
185
193
|
});
|
|
186
194
|
}
|
|
@@ -200,7 +208,7 @@ const setupAdministration = () => {
|
|
|
200
208
|
const createAdminConfigs = (options) => {
|
|
201
209
|
setupAdministration();
|
|
202
210
|
|
|
203
|
-
|
|
211
|
+
let adminConfigs = config.buildThemes.map((themeName, index) => {
|
|
204
212
|
let resourcesPaths = getResourcesPaths(themeName, options);
|
|
205
213
|
let themeSlug = ChangeCase.kebabCase(themeName);
|
|
206
214
|
let themeOptions = {
|
|
@@ -232,6 +240,11 @@ const createAdminConfigs = (options) => {
|
|
|
232
240
|
|
|
233
241
|
return merged;
|
|
234
242
|
});
|
|
243
|
+
|
|
244
|
+
// Limit how many theme compilers run concurrently (webpack MultiCompiler).
|
|
245
|
+
adminConfigs.parallelism = config.buildParallelism;
|
|
246
|
+
|
|
247
|
+
return adminConfigs;
|
|
235
248
|
};
|
|
236
249
|
|
|
237
250
|
module.exports = {
|