@pixolith/webpack-sw6-config 12.0.1 → 12.0.3

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.1",
4
+ "version": "12.0.3",
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": "fb65e2559e4669b1729bf68c64e28b9117cafe7e",
24
+ "gitHead": "5b13ac682aa7897d252365ff02a153d7295afb12",
25
25
  "dependencies": {
26
26
  "@babel/cli": "7.25.9",
27
27
  "@babel/core": "^7.26.0",
@@ -30,14 +30,14 @@
30
30
  "@babel/preset-env": "7.26.0",
31
31
  "@babel/preset-typescript": "7.26.0",
32
32
  "@pixolith/eslint-config-sw6": "^12.0.0",
33
- "@pixolith/external-svg-sprite-loader": "^12.0.2",
33
+ "@pixolith/external-svg-sprite-loader": "^12.0.1",
34
34
  "@pixolith/stylelint-config-standard": "^12.0.0",
35
35
  "@pixolith/webpack-assets-copy-plugin": "^12.0.0",
36
36
  "@pixolith/webpack-filename-linter-plugin": "^12.0.0",
37
37
  "@pixolith/webpack-hook-plugin": "^12.0.0",
38
- "@pixolith/webpack-sw6-plugin-map-emitter": "^12.0.0",
38
+ "@pixolith/webpack-sw6-plugin-map-emitter": "^12.0.3",
39
39
  "@pixolith/webpack-twig-assets-emitter-plugin": "^12.0.0",
40
- "@pixolith/webpack-watcher": "^12.0.0",
40
+ "@pixolith/webpack-watcher": "^12.0.3",
41
41
  "@swc/core": "^1.9.3",
42
42
  "autoprefixer": "^10.4.20",
43
43
  "babel-loader": "^9.2.1",
package/src/config.js CHANGED
@@ -27,7 +27,13 @@ const config = {
27
27
  jsFolder: process.env.JS_FOLDER || 'js',
28
28
  iconsFolder: process.env.ICONS_FOLDER || 'icons',
29
29
 
30
- spriteOrder: process.env.SPRITE_ORDER ?? ['pxsw/basic-theme', 'PxswBasicTheme', '**', 'pxsw/customer-theme', 'PxswCustomerTheme'],
30
+ spriteOrder: process.env.SPRITE_ORDER ?? [
31
+ 'pxsw/basic-theme',
32
+ 'PxswBasicTheme',
33
+ '**',
34
+ 'pxsw/customer-theme',
35
+ 'PxswCustomerTheme',
36
+ ],
31
37
  ignoreIcons: process.env.IGNORE_ICONS ?? [],
32
38
 
33
39
  mediaQueries: process.env.MEDIA_QUERIES || false,
@@ -40,12 +46,25 @@ const config = {
40
46
  pluginsPublicPath: Path.join(process.cwd(), 'public'),
41
47
  vendorPublicPath: Path.join(process.cwd(), 'public/bundles'),
42
48
 
43
- shopwareVendorPath: Path.join(process.cwd(), 'vendor/shopware/storefront/Resources/app/storefront/vendor'),
44
- shopwarePluginPath: Path.join(process.cwd(), 'vendor/shopware/storefront/Resources/app/storefront/src'),
49
+ shopwareVendorPath: Path.join(
50
+ process.cwd(),
51
+ 'vendor/shopware/storefront/Resources/app/storefront/vendor',
52
+ ),
53
+ shopwarePluginPath: Path.join(
54
+ process.cwd(),
55
+ 'vendor/shopware/storefront/Resources/app/storefront/src',
56
+ ),
45
57
 
46
58
  allowedExtensions: ['.ts', '.js', '.scss', '.css', '.svg'],
59
+
60
+ // Dev server connection settings (used for devServer config + output.publicPath in dev)
61
+ devServerHostname: process.env.DEV_SERVER_HOSTNAME || 'node.px-staging.de',
62
+ devServerPort: process.env.SHOPWARE_MODE === 'administration' ? 8080 : 8081,
63
+ devServerProtocol: process.env.DEV_SERVER_PROTOCOL || 'https',
47
64
  };
48
65
 
66
+ config.devServerPublicUrl = `${config.devServerProtocol}://${config.devServerHostname}:${config.devServerPort}/`;
67
+
49
68
  // PICKED_THEME: optional filter to build/watch a single theme from THEME_NAMES
50
69
  let pickedTheme = process.env.PICKED_THEME
51
70
  ? process.env.PICKED_THEME.trim()
@@ -53,7 +72,9 @@ let pickedTheme = process.env.PICKED_THEME
53
72
 
54
73
  if (pickedTheme && config.themeNames.indexOf(pickedTheme) === -1) {
55
74
  process.stderr.write(
56
- `PICKED_THEME "${pickedTheme}" is not in THEME_NAMES [${config.themeNames.join(', ')}].\n`,
75
+ `PICKED_THEME "${pickedTheme}" is not in THEME_NAMES [${config.themeNames.join(
76
+ ', ',
77
+ )}].\n`,
57
78
  );
58
79
  process.exit(1);
59
80
  }
@@ -74,12 +95,25 @@ const pxRouteSplitPath =
74
95
  : '');
75
96
 
76
97
  // Create a glob regex to match the plugin prefixes
77
- let prefixes = config.pluginPrefixes.split(',').map(p => `${p}*`).join('|');
98
+ let prefixes = config.pluginPrefixes
99
+ .split(',')
100
+ .map((p) => `${p}*`)
101
+ .join('|');
78
102
  const pluginSrcPath = Path.join(config.pluginsBasePath, `+(${prefixes})`);
79
- const vendorSrcPath = Path.join(config.vendorBasePath, `+(${config.pluginPrefixes.replace(',', '|').toLowerCase()})`, '*');
80
-
81
- const pluginMatch = new RegExp(`/plugins\/((${config.pluginPrefixes.replace(',', '|')})\\w*)\/`);
82
- const vendorMatch = new RegExp(`/(vendor\/(${config.pluginPrefixes.replace(',', '|').toLowerCase()})\/[\\w-]*)\/`);
103
+ const vendorSrcPath = Path.join(
104
+ config.vendorBasePath,
105
+ `+(${config.pluginPrefixes.replace(',', '|').toLowerCase()})`,
106
+ '*',
107
+ );
108
+
109
+ const pluginMatch = new RegExp(
110
+ `/plugins\/((${config.pluginPrefixes.replace(',', '|')})\\w*)\/`,
111
+ );
112
+ const vendorMatch = new RegExp(
113
+ `/(vendor\/(${config.pluginPrefixes
114
+ .replace(',', '|')
115
+ .toLowerCase()})\/[\\w-]*)\/`,
116
+ );
83
117
  const routeSplitMatch = new RegExp(`/scss-route-split\/([\\w-]*)`);
84
118
 
85
119
  module.exports = {
@@ -96,11 +130,31 @@ module.exports = {
96
130
  pluginMatch: pluginMatch,
97
131
  vendorMatch: vendorMatch,
98
132
 
99
- sharedScssPluginPath: Path.join(pluginSrcPath, pxEntryPath, config.pxSharedPath, config.scssFolder),
100
- sharedScssVendorPath: Path.join(vendorSrcPath, pxEntryPath, config.pxSharedPath, config.scssFolder),
101
-
102
- sharedIconPluginPath: Path.join(pluginSrcPath, pxEntryPath, config.pxSharedPath, config.iconsFolder),
103
- sharedIconVendorPath: Path.join(vendorSrcPath, pxEntryPath, config.pxSharedPath, config.iconsFolder),
133
+ sharedScssPluginPath: Path.join(
134
+ pluginSrcPath,
135
+ pxEntryPath,
136
+ config.pxSharedPath,
137
+ config.scssFolder,
138
+ ),
139
+ sharedScssVendorPath: Path.join(
140
+ vendorSrcPath,
141
+ pxEntryPath,
142
+ config.pxSharedPath,
143
+ config.scssFolder,
144
+ ),
145
+
146
+ sharedIconPluginPath: Path.join(
147
+ pluginSrcPath,
148
+ pxEntryPath,
149
+ config.pxSharedPath,
150
+ config.iconsFolder,
151
+ ),
152
+ sharedIconVendorPath: Path.join(
153
+ vendorSrcPath,
154
+ pxEntryPath,
155
+ config.pxSharedPath,
156
+ config.iconsFolder,
157
+ ),
104
158
 
105
159
  routeSplitMatch: routeSplitMatch,
106
160
  pluginRouteSplitPath: Path.join(pluginSrcPath, pxRouteSplitPath),
@@ -105,16 +105,14 @@ module.exports = function createDevConfig(themeOptions) {
105
105
  allowedHosts: 'all',
106
106
  client: {
107
107
  webSocketURL: {
108
- hostname: 'node.px-staging.de',
108
+ hostname: config.devServerHostname,
109
109
  protocol: 'wss',
110
- port:
111
- process.env.SHOPWARE_MODE === 'administration'
112
- ? 8080
113
- : 8081,
110
+ port: config.devServerPort,
114
111
  },
115
112
  overlay: {
116
113
  warnings: false,
117
114
  errors: true,
115
+ runtimeErrors: false,
118
116
  },
119
117
  },
120
118
  headers: {
@@ -124,7 +122,7 @@ module.exports = function createDevConfig(themeOptions) {
124
122
  'Access-Control-Allow-Headers':
125
123
  'X-Requested-With, content-type, Authorization',
126
124
  },
127
- port: process.env.SHOPWARE_MODE === 'administration' ? 8080 : 8081,
125
+ port: config.devServerPort,
128
126
  server: !config.isProd
129
127
  ? {
130
128
  type: 'https',
@@ -150,8 +148,9 @@ module.exports = function createDevConfig(themeOptions) {
150
148
  },
151
149
  }
152
150
  : 'http',
151
+ liveReload: false,
153
152
  devMiddleware: {
154
- writeToDisk: true,
153
+ writeToDisk: (filePath) => !filePath.includes('.hot-update.'),
155
154
  },
156
155
  setupMiddlewares: (middlewares, devServer) => {
157
156
  if (!devServer) {
@@ -197,5 +196,8 @@ module.exports = function createDevConfig(themeOptions) {
197
196
  : [],
198
197
  ),
199
198
  watch: false,
199
+ optimization: {
200
+ runtimeChunk: 'single',
201
+ },
200
202
  };
201
203
  };
@@ -14,7 +14,8 @@ module.exports = function createStorefrontConfig(themeOptions) {
14
14
 
15
15
  let outputConfig = {
16
16
  path: config.outputPath,
17
- publicPath: config.assetUrl,
17
+ publicPath: config.isProd ? config.assetUrl : config.devServerPublicUrl,
18
+ crossOriginLoading: config.isProd ? false : 'anonymous',
18
19
  chunkFilename: (chunkData) => {
19
20
  return `js/chunk[name]${config.isProd ? '.[contenthash]' : ''}.js`;
20
21
  },