@pixolith/webpack-sw6-config 8.1.5 → 8.2.0

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": "8.1.5",
4
+ "version": "8.2.0",
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": "da6ef031102a9a90ae5fe7b2befab375ffed7e7a",
24
+ "gitHead": "599d1595463fb7783af832b4c804a990d6fd9a8c",
25
25
  "dependencies": {
26
26
  "@babel/cli": "7.23.4",
27
27
  "@babel/core": "^7.23.7",
@@ -30,13 +30,13 @@
30
30
  "@babel/preset-env": "7.23.7",
31
31
  "@babel/preset-typescript": "7.23.3",
32
32
  "@pixolith/eslint-config-sw6": "^8.0.0",
33
- "@pixolith/external-svg-sprite-loader": "^8.0.0",
33
+ "@pixolith/external-svg-sprite-loader": "^8.2.0",
34
34
  "@pixolith/stylelint-config-standard": "^8.0.0",
35
35
  "@pixolith/webpack-assets-copy-plugin": "^8.0.0",
36
36
  "@pixolith/webpack-filename-linter-plugin": "^8.0.0",
37
37
  "@pixolith/webpack-hook-plugin": "^8.0.0",
38
- "@pixolith/webpack-sw6-plugin-map-emitter": "^8.1.4",
39
- "@pixolith/webpack-watcher": "^8.0.4",
38
+ "@pixolith/webpack-sw6-plugin-map-emitter": "^8.1.6",
39
+ "@pixolith/webpack-watcher": "^8.1.6",
40
40
  "@swc/core": "^1.7.0",
41
41
  "autoprefixer": "^10.4.14",
42
42
  "babel-loader": "^9.1.2",
package/src/index.js CHANGED
@@ -11,7 +11,6 @@ const Consola = require('consola');
11
11
  const setup = () => {
12
12
  Consola.info('Cleaning output folder');
13
13
  watcher.clean();
14
- Consola.info('Building index files');
15
14
  watcher.run();
16
15
  console.table({
17
16
  isProd: isProd,
@@ -20,7 +19,6 @@ const setup = () => {
20
19
  publicPath: process.env.PUBLIC_PATH,
21
20
  sharedAssetPath: process.env.SHARED_SCSS_PATH,
22
21
  shopwareMode: process.env.SHOPWARE_MODE,
23
- jsTranspile: process.env.JS_TRANSPILE,
24
22
  globalResourcesPaths: process.env.RESOURCES_PATHS,
25
23
  debug: process.env.DEBUG || false,
26
24
  version: pkg.version,
@@ -4,14 +4,14 @@ const Path = require('path'),
4
4
  privatePath = process.env.PLUGIN_PATH,
5
5
  vendorPath = process.env.VENDOR_PATH,
6
6
  publicPath = process.env.PUBLIC_PATH,
7
- spritePath = process.env.SPRITE_PATH ?? 'custom/static-plugins/PxswTheme/src/Resources/views/administration',
7
+ spriteOrder = process.env.SPRITE_ORDER ?? ['pxsw/basic-theme', 'PxswBasicTheme', '**', 'pxsw/customer-theme', 'PxswCustomerTheme'],
8
+ ignoreIcons = process.env.IGNORE_ICONS ?? [],
8
9
  isProd = process.env.NODE_ENV === 'production',
9
10
  ChangeCase = require('change-case'),
10
11
  MiniCssExtractPlugin = require('mini-css-extract-plugin'),
11
12
  Consola = require('consola'),
12
13
  AssetsCopyPlugin = require('@pixolith/webpack-assets-copy-plugin'),
13
14
  SvgStorePlugin = require('@pixolith/external-svg-sprite-loader'),
14
- HookPlugin = require('@pixolith/webpack-hook-plugin'),
15
15
  outputPath = Path.resolve(process.cwd(), publicPath),
16
16
  outputConfig = {
17
17
  path: outputPath,
@@ -96,9 +96,11 @@ module.exports = {
96
96
  {
97
97
  loader: SvgStorePlugin.loader,
98
98
  options: {
99
- name: 'sprite/sprite_uses.svg',
99
+ name: 'sprite/sprite.svg',
100
100
  iconName: '[name]',
101
- onlySymbols: false,
101
+ overrideOrder: spriteOrder,
102
+ ignoreIconsByName: ignoreIcons,
103
+ onlySymbols: true,
102
104
  },
103
105
  },
104
106
  {
@@ -131,70 +133,13 @@ module.exports = {
131
133
  },
132
134
  output: outputConfig,
133
135
  plugins: [
134
- new HookPlugin({
135
- beforeCompile(compiler, callback) {
136
- let path = Path.join(process.cwd(), publicPath, 'sprite'),
137
- filename = 'sprite_uses.svg',
138
- exists = Fs.existsSync(Path.join(path, filename));
139
-
140
- if (!exists) {
141
- Fs.mkdirSync(path, {
142
- recursive: true,
143
- });
144
- Fs.appendFile(Path.join(path, filename), '#', (err) => {
145
- if (err) {
146
- throw err;
147
- }
148
- });
149
- }
150
-
151
- callback();
152
- },
153
-
154
- afterEmit(compiler, callback) {
155
- let spriteInputPath = Path.join(
156
- process.cwd(),
157
- publicPath,
158
- 'sprite/sprite_uses.svg',
159
- );
160
- let spriteOutputPath = Path.join(
161
- process.cwd(),
162
- spritePath,
163
- ),
164
- spritOutputFilename = '_sprite_uses.svg';
165
-
166
- let exists = Fs.existsSync(spriteOutputPath);
167
-
168
- if (!exists) {
169
- Fs.mkdirSync(spriteOutputPath, {
170
- recursive: true,
171
- });
172
- }
173
-
174
- Fs.copyFileSync(
175
- spriteInputPath,
176
- Path.join(spriteOutputPath, spritOutputFilename),
177
- );
178
- callback();
179
- },
180
- }),
181
-
182
- new SvgStorePlugin({
183
- sprite: {
184
- startX: 10,
185
- startY: 10,
186
- deltaX: 20,
187
- deltaY: 20,
188
- iconHeight: 48,
189
- },
190
- }),
191
-
136
+ new SvgStorePlugin(),
192
137
  new MiniCssExtractPlugin(miniCssChunksConfig),
193
138
  ].concat(
194
139
  isProd ?
195
140
  new AssetsCopyPlugin({
196
141
  includes: ['js', 'css'],
197
- ignoreFiles: [/[-\w.]*.hot-update.js/, /sprite\/sprite_uses.svg/],
142
+ ignoreFiles: [/[-\w.]*.hot-update.js/],
198
143
  files: [
199
144
  {
200
145
  from: publicPath,
@@ -101,7 +101,7 @@ module.exports = {
101
101
  webSocketURL: {
102
102
  hostname: 'node.px-staging.de',
103
103
  protocol: 'wss',
104
- port: 8080,
104
+ port: process.env.SHOPWARE_MODE === 'administration' ? 8080 : 8081,
105
105
  },
106
106
  overlay: {
107
107
  warnings: false,
@@ -115,6 +115,7 @@ module.exports = {
115
115
  'Access-Control-Allow-Headers':
116
116
  'X-Requested-With, content-type, Authorization',
117
117
  },
118
+ port: process.env.SHOPWARE_MODE === 'administration' ? 8080 : 8081,
118
119
  server: !isProd
119
120
  ? {
120
121
  type: 'https',
@@ -143,13 +144,17 @@ module.exports = {
143
144
  devMiddleware: {
144
145
  writeToDisk: true,
145
146
  },
146
- onAfterSetupMiddleware: function(devServer) {
147
- if (!isProd) {
148
- Consola.success(
149
- `Starting webpack in [${process.env.NODE_ENV}] with [${process.env.SHOPWARE_MODE}]`,
150
- );
151
- watcher.watch();
147
+ setupMiddlewares: (middlewares, devServer) => {
148
+ if (!devServer) {
149
+ throw new Error("webpack-dev-server is not defined")
152
150
  }
151
+
152
+ Consola.success(
153
+ `Starting webpack in [${process.env.NODE_ENV}] with [${process.env.SHOPWARE_MODE}]`,
154
+ );
155
+ watcher.watch();
156
+
157
+ return middlewares;
153
158
  },
154
159
  },
155
160
  plugins: [
@@ -3,7 +3,8 @@ const Path = require('path'),
3
3
  MiniCssExtractPlugin = require('mini-css-extract-plugin'),
4
4
  privatePath = process.env.PLUGIN_PATH,
5
5
  vendorPath = process.env.VENDOR_PATH,
6
- spritePath = process.env.SPRITE_PATH ?? 'custom/static-plugins/PxswTheme/src/Resources/views/storefront',
6
+ spriteOrder = process.env.SPRITE_ORDER ?? ['pxsw/basic-theme', 'PxswBasicTheme', '**', 'pxsw/customer-theme', 'PxswCustomerTheme'],
7
+ ignoreIcons = process.env.IGNORE_ICONS ?? [],
7
8
  swNodePath = process.env.SW_NODE_PATH ?? './vendor/shopware/storefront/Resources/app/storefront/vendor',
8
9
  swAliasPath = process.env.SW_ALIAS_PATH ?? '/vendor/shopware/storefront/Resources/app/storefront/src',
9
10
  isProd = process.env.NODE_ENV === 'production',
@@ -14,7 +15,6 @@ const Path = require('path'),
14
15
  SvgStorePlugin = require('@pixolith/external-svg-sprite-loader'),
15
16
  publicPath = process.env.PUBLIC_PATH,
16
17
  ASSET_URL = process.env.ASSET_URL || '/',
17
- HookPlugin = require('@pixolith/webpack-hook-plugin'),
18
18
  outputConfig = {
19
19
  path: Path.join(process.cwd(), publicPath),
20
20
  publicPath: ASSET_URL,
@@ -132,6 +132,8 @@ module.exports = {
132
132
  options: {
133
133
  name: 'sprite/sprite.svg',
134
134
  iconName: '[name]',
135
+ overrideOrder: spriteOrder,
136
+ ignoreIconsByName: ignoreIcons,
135
137
  onlySymbols: true,
136
138
  },
137
139
  },
@@ -165,68 +167,12 @@ module.exports = {
165
167
  },
166
168
  output: outputConfig,
167
169
  plugins: [
168
- new HookPlugin({
169
- beforeCompile(compiler, callback) {
170
- let path = Path.join(process.cwd(), publicPath, 'sprite'),
171
- filename = 'sprite.svg',
172
- exists = Fs.existsSync(Path.join(path, filename));
173
-
174
- if (!exists) {
175
- Fs.mkdirSync(path, {
176
- recursive: true,
177
- });
178
- Fs.appendFile(Path.join(path, filename), '#', (err) => {
179
- if (err) {
180
- throw err;
181
- }
182
- });
183
- }
184
-
185
- callback();
186
- },
187
-
188
- afterEmit(compiler, callback) {
189
- let spriteInputPath = Path.join(
190
- process.cwd(),
191
- publicPath,
192
- 'sprite/sprite.svg',
193
- );
194
- let spriteOutputPath = Path.join(
195
- process.cwd(),
196
- spritePath,
197
- ),
198
- spritOutputFilename = '_sprite.svg';
199
-
200
- let exists = Fs.existsSync(spriteOutputPath);
201
-
202
- if (!exists) {
203
- Fs.mkdirSync(spriteOutputPath, {
204
- recursive: true,
205
- });
206
- }
207
-
208
- Fs.copyFileSync(
209
- spriteInputPath,
210
- Path.join(spriteOutputPath, spritOutputFilename),
211
- );
212
- callback();
213
- },
214
- }),
215
-
216
170
  new Sw6PluginMapEmitterPlugin({
217
171
  includes: ['js', 'css'],
218
172
  ignoreFiles: [/.*icons.*\.js/, /.*chunk.*\.js/],
219
173
  }),
220
174
 
221
- new SvgStorePlugin({
222
- sprite: {
223
- startX: 10,
224
- startY: 10,
225
- deltaX: 20,
226
- deltaY: 20,
227
- iconHeight: 48,
228
- },
229
- }),
175
+ new SvgStorePlugin(),
230
176
 
231
177
  new MiniCssExtractPlugin(miniCssChunksConfig),
232
178
  ],