@pixolith/webpack-sw6-config 12.0.3 → 12.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixolith/webpack-sw6-config",
3
3
  "public": true,
4
- "version": "12.0.3",
4
+ "version": "12.0.5",
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": "5b13ac682aa7897d252365ff02a153d7295afb12",
24
+ "gitHead": "be9ef885019f0dfec8031bdfba51df187d92efec",
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
- return config.buildThemes.map((themeName, index) => {
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
- return config.buildThemes.map((themeName, index) => {
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 = {
@@ -10,9 +10,25 @@ const webpack = require('webpack'),
10
10
  watcher = require('@pixolith/webpack-watcher'),
11
11
  Glob = require('glob'),
12
12
  HookPlugin = require('@pixolith/webpack-hook-plugin'),
13
- Sass = require('sass'),
14
13
  TimeFixPlugin = require('time-fix-plugin');
15
14
 
15
+ const sassLogger = {
16
+ warn(message, options) {
17
+ let stack = options && options.stack;
18
+ // Skip Sass's own deprecation warnings and its end-of-run "N
19
+ // deprecations omitted" summaries (Sass gives those a "null" stack);
20
+ // surface only intentional @warn from project SCSS.
21
+ if ((options && options.deprecation) || !stack || stack === 'null') {
22
+ return;
23
+ }
24
+
25
+ Consola.warn(`[sass] ${message}\n${stack.trimEnd()}`);
26
+ },
27
+ debug(message) {
28
+ Consola.info(`[sass] ${message}`);
29
+ },
30
+ };
31
+
16
32
  module.exports = function createDevConfig(themeOptions) {
17
33
  let resourcesPaths =
18
34
  themeOptions && themeOptions.resourcesPaths
@@ -77,7 +93,7 @@ module.exports = function createDevConfig(themeOptions) {
77
93
  additionalData: `$asset_url: '${config.assetUrl}';`,
78
94
  sassOptions: {
79
95
  quietDeps: true,
80
- logger: Sass.Logger.silent,
96
+ logger: sassLogger,
81
97
  },
82
98
  },
83
99
  },