@pixolith/webpack-sw6-config 9.0.0 → 11.0.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": "9.0.0",
4
+ "version": "11.0.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": "07feda64fe1e987ef572a4ad06619712eccd4b6e",
24
+ "gitHead": "d0ba47858dc6ddfeaadceaecea5ea59e97c96717",
25
25
  "dependencies": {
26
26
  "@babel/cli": "7.25.9",
27
27
  "@babel/core": "^7.26.0",
@@ -29,14 +29,15 @@
29
29
  "@babel/plugin-proposal-decorators": "7.25.9",
30
30
  "@babel/preset-env": "7.26.0",
31
31
  "@babel/preset-typescript": "7.26.0",
32
- "@pixolith/eslint-config-sw6": "^9.0.0",
33
- "@pixolith/external-svg-sprite-loader": "^9.0.0",
34
- "@pixolith/stylelint-config-standard": "^9.0.0",
35
- "@pixolith/webpack-assets-copy-plugin": "^9.0.0",
36
- "@pixolith/webpack-filename-linter-plugin": "^9.0.0",
37
- "@pixolith/webpack-hook-plugin": "^9.0.0",
38
- "@pixolith/webpack-sw6-plugin-map-emitter": "^9.0.0",
39
- "@pixolith/webpack-watcher": "^9.0.0",
32
+ "@pixolith/eslint-config-sw6": "^11.0.0",
33
+ "@pixolith/external-svg-sprite-loader": "^11.0.0",
34
+ "@pixolith/stylelint-config-standard": "^11.0.0",
35
+ "@pixolith/webpack-assets-copy-plugin": "^11.0.0",
36
+ "@pixolith/webpack-filename-linter-plugin": "^11.0.0",
37
+ "@pixolith/webpack-hook-plugin": "^11.0.0",
38
+ "@pixolith/webpack-sw6-plugin-map-emitter": "^11.0.0",
39
+ "@pixolith/webpack-twig-assets-emitter-plugin": "^11.0.0",
40
+ "@pixolith/webpack-watcher": "^11.0.0",
40
41
  "@swc/core": "^1.9.3",
41
42
  "autoprefixer": "^10.4.20",
42
43
  "babel-loader": "^9.2.1",
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  presets: [
3
3
  ['@babel/preset-env', {
4
4
  useBuiltIns: 'entry',
package/src/config.js CHANGED
@@ -4,8 +4,9 @@ const Path = require('path');
4
4
 
5
5
  const config = {
6
6
  isProd: process.env.NODE_ENV === 'production',
7
- isDebug: !!process.env.DEBUG || true,
7
+ isDebug: !!process.env.DEBUG || false,
8
8
  shopwareMode: process.env.SHOPWARE_MODE,
9
+ shopwareVersion: process.env.SHOPWARE_VERSION || '6.6',
9
10
 
10
11
  assetUrl: process.env.ASSET_URL || '/',
11
12
  pluginPrefixes: process.env.PLUGIN_PREFIXES || 'Pxsw',
@@ -31,13 +32,11 @@ const config = {
31
32
  shopwareVendorPath: Path.join(process.cwd(), 'vendor/shopware/storefront/Resources/app/storefront/vendor'),
32
33
  shopwarePluginPath: Path.join(process.cwd(), 'vendor/shopware/storefront/Resources/app/storefront/src'),
33
34
 
34
- spriteOutputPath: Path.join(process.cwd(), 'custom/plugins/PxswTheme/src/Resources/views'),
35
-
36
35
  allowedExtensions: ['.ts', '.js', '.scss', '.css', '.svg']
37
36
  }
38
37
 
39
- const pxEntryPath = process.env.PX_ENTRY_PATH || process.env.SHOPWARE_MODE === 'storefront' ? 'src/Resources/app/storefront/private' : 'src/Resources/app/administration/src';
40
- const pxRouteSplitPath = process.env.PX_ROUTE_SPLIT_PATH || process.env.SHOPWARE_MODE === 'storefront' ? 'src/Resources/app/storefront/private/scss-route-split/*' : '';
38
+ const pxEntryPath = process.env.PX_ENTRY_PATH || (process.env.SHOPWARE_MODE === 'storefront' ? 'src/Resources/app/storefront/private' : 'src/Resources/app/administration/src');
39
+ const pxRouteSplitPath = process.env.PX_ROUTE_SPLIT_PATH || (process.env.SHOPWARE_MODE === 'storefront' ? 'src/Resources/app/storefront/private/scss-route-split/*' : '');
41
40
 
42
41
  // Create a glob regex to match the plugin prefixes
43
42
  let prefixes = config.pluginPrefixes.split(',').map(p => `${p}*`).join('|');
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  'plugins': {
3
3
  // to edit target browsers: use "browserslist" field in package.json
4
4
  'autoprefixer': {},
@@ -8,30 +8,29 @@ const Path = require('path'),
8
8
  Consola = require('consola'),
9
9
  AssetsCopyPlugin = require('@pixolith/webpack-assets-copy-plugin'),
10
10
  SvgStorePlugin = require('@pixolith/external-svg-sprite-loader'),
11
+ TwigAssetEmitterPlugin = require('@pixolith/webpack-twig-assets-emitter-plugin'),
11
12
  outputConfig = {
12
13
  path: config.outputPath,
13
14
  publicPath: '/',
14
15
  filename: (chunkData) => {
15
- let pluginName = chunkData.chunk.name
16
- .toLowerCase()
17
- .replace('vendor-', '')
18
- .replace('pxsw-pxsw-', 'pxsw-');
19
- return `${pluginName.replace(
20
- /-/g,
21
- '',
22
- )}/administration/js/${pluginName}.js`;
16
+ let pluginName = chunkData.chunk.name.toLowerCase().replace('pxsw-pxsw-', 'pxsw-');
17
+ pluginName = config.shopwareVersion === '6.6' ? pluginName.replace('vendor-', '') : pluginName;
18
+ return config.shopwareVersion === '6.6' ?
19
+ `${pluginName.replace(/-/g, '',)}/administration/js/${pluginName}.js` :
20
+ `js/${pluginName}${
21
+ config.isProd ? '.admin.[contenthash]' : ''
22
+ }.js`;
23
23
  }
24
24
  },
25
25
  miniCssChunksConfig = {
26
26
  filename: (chunkData) => {
27
- let pluginName = chunkData.chunk.name
28
- .toLowerCase()
29
- .replace('vendor-', '')
30
- .replace('pxsw-pxsw-', 'pxsw-');
31
- return `${pluginName.replace(
32
- /-/g,
33
- '',
34
- )}/administration/css/${pluginName}.css`;
27
+ let pluginName = chunkData.chunk.name.toLowerCase().replace('pxsw-pxsw-', 'pxsw-');
28
+ pluginName = config.shopwareVersion === '6.6' ? pluginName.replace('vendor-', '') : pluginName;
29
+ return config.shopwareVersion === '6.6' ?
30
+ `${pluginName.replace(/-/g, '',)}/administration/css/${pluginName}.css` :
31
+ `css/${pluginName}${
32
+ config.isProd ? '.admin.[contenthash]' : ''
33
+ }.css`;
35
34
  }
36
35
  }
37
36
 
@@ -58,12 +57,9 @@ module.exports = {
58
57
  console.table({...entriesPlugins, ...entriesVendor });
59
58
  }
60
59
 
61
- console.table({...entriesPlugins, ...entriesVendor });
62
-
63
60
  return {...entriesPlugins, ...entriesVendor };
64
61
  },
65
62
  module: {
66
- // loader order is from right to left or from bottom to top depending on the notation but basicly always reverse
67
63
  rules: [
68
64
  {
69
65
  test: /\.js$/,
@@ -133,7 +129,7 @@ module.exports = {
133
129
  new SvgStorePlugin(),
134
130
  new MiniCssExtractPlugin(miniCssChunksConfig),
135
131
  ].concat(
136
- config.isProd ?
132
+ config.isProd && config.shopwareVersion === '6.6' ?
137
133
  new AssetsCopyPlugin({
138
134
  includes: ['js', 'css'],
139
135
  ignoreFiles: [/[-\w.]*.hot-update.js/],
@@ -166,6 +162,17 @@ module.exports = {
166
162
  },
167
163
  ],
168
164
  }) : [],
165
+ ).concat(
166
+ config.isProd && config.shopwareVersion !== '6.6' ?
167
+ new TwigAssetEmitterPlugin({
168
+ includes: ['js', 'css'],
169
+ ignoreFiles: [/.*icons.*\.js/],
170
+ template: {
171
+ admin: {
172
+ filename: 'index.html.twig',
173
+ },
174
+ },
175
+ }) : [],
169
176
  ),
170
177
 
171
178
  optimization: {
@@ -23,11 +23,11 @@ module.exports = {
23
23
  ],
24
24
  alias: {
25
25
  src: Path.resolve(config.shopwarePluginPath),
26
+ vendor: Path.resolve(config.shopwareVendorPath),
26
27
  },
27
28
  },
28
29
  devtool: 'inline-cheap-module-source-map',
29
30
  module: {
30
- // loader order is from right to left or from bottom to top depending on the notation but basicly always reverse
31
31
  rules: [
32
32
  {
33
33
  test: /(\.scss|\.css)$/,
@@ -186,6 +186,7 @@ module.exports = {
186
186
  process.env.NODE_ENV || 'development',
187
187
  ),
188
188
  'process.env.ASSET_URL': JSON.stringify(config.assetUrl),
189
+ 'process.env.RESOURCES_PATHS': JSON.stringify(process.env.RESOURCES_PATHS || '[]'),
189
190
  }),
190
191
  ].concat(
191
192
  config.isProd && config.mediaQueries
@@ -1,11 +1,7 @@
1
- const config = require('./config'),
2
- webpack = require('webpack'),
1
+ const webpack = require('webpack'),
3
2
  TerserPlugin = require('terser-webpack-plugin'),
4
3
  CssMinimizerPlugin = require('css-minimizer-webpack-plugin'),
5
- StyleLintPlugin = require('stylelint-webpack-plugin'),
6
- Glob = require('glob'),
7
4
  RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts'),
8
- Path = require('path'),
9
5
  productionConfig = {
10
6
  devtool: 'nosources-source-map',
11
7
  performance: {
@@ -51,17 +47,7 @@ const config = require('./config'),
51
47
  },
52
48
  }),
53
49
  new RemoveEmptyScriptsPlugin(),
54
- ].concat(
55
- //Glob.sync(Path.join(config.pluginSrcPath, '/**/*.s?(a|c)ss')).length
56
- // ? new StyleLintPlugin({
57
- // files: '**/Pxsw*/**/*.s?(a|c)ss',
58
- // failOnError: false,
59
- // fix: false,
60
- // configFile: Path.join(__dirname, 'stylelint.config.js'),
61
- // })
62
- // : [],
63
- []
64
- ),
50
+ ],
65
51
  stats: 'normal',
66
52
  };
67
53
 
@@ -68,7 +68,6 @@ module.exports = {
68
68
  return { ...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor };
69
69
  },
70
70
  module: {
71
- // loader order is from right to left or from bottom to top depending on the notation but basicly always reverse
72
71
  rules: [
73
72
  {
74
73
  test: /\.js$/,