@pixolith/webpack-sw6-config 10.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,8 +1,7 @@
1
1
  {
2
2
  "name": "@pixolith/webpack-sw6-config",
3
3
  "public": true,
4
- "version": "10.0.0",
5
- "type": "module",
4
+ "version": "11.0.0",
6
5
  "description": "",
7
6
  "main": "src/index.js",
8
7
  "scripts": {},
@@ -22,7 +21,7 @@
22
21
  "url": "https://github.com/pixolith/webpack-plugins/issues"
23
22
  },
24
23
  "homepage": "https://github.com/pixolith/webpack-plugins/tree/master/packages/webpack-hook-plugin/#readme",
25
- "gitHead": "663cc0d270bfd9b70dac783a86d902c8969942e7",
24
+ "gitHead": "d0ba47858dc6ddfeaadceaecea5ea59e97c96717",
26
25
  "dependencies": {
27
26
  "@babel/cli": "7.25.9",
28
27
  "@babel/core": "^7.26.0",
@@ -30,14 +29,15 @@
30
29
  "@babel/plugin-proposal-decorators": "7.25.9",
31
30
  "@babel/preset-env": "7.26.0",
32
31
  "@babel/preset-typescript": "7.26.0",
33
- "@pixolith/eslint-config-sw6": "^10.0.0",
34
- "@pixolith/external-svg-sprite-loader": "^10.0.0",
35
- "@pixolith/stylelint-config-standard": "^10.0.0",
36
- "@pixolith/webpack-assets-copy-plugin": "^10.0.0",
37
- "@pixolith/webpack-filename-linter-plugin": "^10.0.0",
38
- "@pixolith/webpack-hook-plugin": "^10.0.0",
39
- "@pixolith/webpack-sw6-plugin-map-emitter": "^10.0.0",
40
- "@pixolith/webpack-watcher": "^10.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",
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
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- import Path from 'path';
3
+ const Path = require('path');
4
4
 
5
5
  const config = {
6
6
  isProd: process.env.NODE_ENV === 'production',
7
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',
@@ -20,7 +21,7 @@ const config = {
20
21
 
21
22
  mediaQueries: process.env.MEDIA_QUERIES || false,
22
23
 
23
- outputPath: Path.join(process.cwd(), process.env.PUBLIC_PATH ?? ''),
24
+ outputPath: Path.join(process.cwd(), process.env.PUBLIC_PATH),
24
25
 
25
26
  vendorBasePath: Path.join(process.cwd(), 'vendor'),
26
27
  pluginsBasePath: Path.join(process.cwd(), 'custom/plugins'),
@@ -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('|');
@@ -48,7 +47,7 @@ const pluginMatch = new RegExp(`/plugins\/((${config.pluginPrefixes.replace(',',
48
47
  const vendorMatch = new RegExp(`/(vendor\/(${config.pluginPrefixes.replace(',', '|').toLowerCase()})\/[\\w-]*)\/`);
49
48
  const routeSplitMatch = new RegExp(`/scss-route-split\/([\\w-]*)`);
50
49
 
51
- export default {
50
+ module.exports = {
52
51
  ...config,
53
52
  pluginSrcPath: Path.join(pluginSrcPath, pxEntryPath),
54
53
  pluginScssPath: Path.join(pluginSrcPath, pxEntryPath, config.scssFolder),
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import config from './config.js';
2
- import production from './webpack.config.production.js';
3
- import storefront from './webpack.config.storefront.js';
4
- import dev from './webpack.config.dev.js';
5
- import administration from './webpack.config.administration.js';
6
- import pkg from './../package.json' assert { type: 'json' };
7
- import watcher from '@pixolith/webpack-watcher';
8
- import {merge} from 'webpack-merge';
1
+ const config = require('./config');
2
+ const production = require('./webpack.config.production');
3
+ const storefront = require('./webpack.config.storefront');
4
+ const dev = require('./webpack.config.dev');
5
+ const administration = require('./webpack.config.administration');
6
+ const pkg = require('./../package.json');
7
+ const watcher = require('@pixolith/webpack-watcher');
8
+ const { merge } = require('webpack-merge');
9
9
 
10
10
  const setup = () => {
11
11
  watcher.clean(config);
@@ -36,5 +36,7 @@ const setup = () => {
36
36
 
37
37
  setup();
38
38
 
39
- export const storefrontConfig = merge(dev, storefront, config.isProd ? production : {});
40
- export const administrationConfig = merge(dev, administration, config.isProd ? production : {});
39
+ module.exports = {
40
+ storefront: merge(dev, storefront, config.isProd ? production : {}),
41
+ administration: merge(dev, administration, config.isProd ? production : {}),
42
+ };
@@ -1,43 +1,40 @@
1
- import config from './config.js';
2
- import Path from 'path';
3
- import Fs from 'fs';
4
- import Entry from 'webpack-glob-entry';
5
- import * as ChangeCase from 'change-case';
6
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
7
- import Consola from 'consola';
8
- import AssetsCopyPlugin from '@pixolith/webpack-assets-copy-plugin';
9
- import SvgStorePlugin from '@pixolith/external-svg-sprite-loader';
1
+ const config = require('./config');
10
2
 
11
- const __dirname = import.meta.dirname;
12
-
13
- const outputConfig = {
3
+ const Path = require('path'),
4
+ Fs = require('fs'),
5
+ Entry = require('webpack-glob-entry'),
6
+ ChangeCase = require('change-case'),
7
+ MiniCssExtractPlugin = require('mini-css-extract-plugin'),
8
+ Consola = require('consola'),
9
+ AssetsCopyPlugin = require('@pixolith/webpack-assets-copy-plugin'),
10
+ SvgStorePlugin = require('@pixolith/external-svg-sprite-loader'),
11
+ TwigAssetEmitterPlugin = require('@pixolith/webpack-twig-assets-emitter-plugin'),
12
+ outputConfig = {
14
13
  path: config.outputPath,
15
14
  publicPath: '/',
16
15
  filename: (chunkData) => {
17
- let pluginName = chunkData.chunk.name
18
- .toLowerCase()
19
- .replace('vendor-', '')
20
- .replace('pxsw-pxsw-', 'pxsw-');
21
- return `${pluginName.replace(
22
- /-/g,
23
- '',
24
- )}/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`;
25
23
  }
26
24
  },
27
25
  miniCssChunksConfig = {
28
26
  filename: (chunkData) => {
29
- let pluginName = chunkData.chunk.name
30
- .toLowerCase()
31
- .replace('vendor-', '')
32
- .replace('pxsw-pxsw-', 'pxsw-');
33
- return `${pluginName.replace(
34
- /-/g,
35
- '',
36
- )}/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`;
37
34
  }
38
35
  }
39
36
 
40
- export default {
37
+ module.exports = {
41
38
  entry: () => {
42
39
  let entriesPlugins = Entry(
43
40
  (filePath) =>
@@ -60,12 +57,9 @@ export default {
60
57
  console.table({...entriesPlugins, ...entriesVendor });
61
58
  }
62
59
 
63
- console.table({...entriesPlugins, ...entriesVendor });
64
-
65
60
  return {...entriesPlugins, ...entriesVendor };
66
61
  },
67
62
  module: {
68
- // loader order is from right to left or from bottom to top depending on the notation but basicly always reverse
69
63
  rules: [
70
64
  {
71
65
  test: /\.js$/,
@@ -135,7 +129,7 @@ export default {
135
129
  new SvgStorePlugin(),
136
130
  new MiniCssExtractPlugin(miniCssChunksConfig),
137
131
  ].concat(
138
- config.isProd ?
132
+ config.isProd && config.shopwareVersion === '6.6' ?
139
133
  new AssetsCopyPlugin({
140
134
  includes: ['js', 'css'],
141
135
  ignoreFiles: [/[-\w.]*.hot-update.js/],
@@ -168,6 +162,17 @@ export default {
168
162
  },
169
163
  ],
170
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
+ }) : [],
171
176
  ),
172
177
 
173
178
  optimization: {
@@ -1,20 +1,19 @@
1
- import config from './config.js';
2
- import webpack from 'webpack';
3
- import Path from 'path';
4
- import Consola from 'consola';
5
- import Fs from 'fs';
6
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
7
- import MediaQueryPlugin from 'media-query-plugin';
8
- import ESLintPlugin from 'eslint-webpack-plugin';
9
- import watcher from '@pixolith/webpack-watcher';
10
- import * as Glob from 'glob';
11
- import HookPlugin from '@pixolith/webpack-hook-plugin';
12
- import * as Sass from 'sass';
13
- import TimeFixPlugin from 'time-fix-plugin';
1
+ const config = require('./config');
14
2
 
15
- const __dirname = import.meta.dirname;
3
+ const webpack = require('webpack'),
4
+ Path = require('path'),
5
+ Consola = require('consola'),
6
+ Fs = require('fs'),
7
+ MiniCssExtractPlugin = require('mini-css-extract-plugin'),
8
+ MediaQueryPlugin = require('media-query-plugin'),
9
+ ESLintPlugin = require('eslint-webpack-plugin'),
10
+ watcher = require('@pixolith/webpack-watcher'),
11
+ Glob = require('glob'),
12
+ HookPlugin = require('@pixolith/webpack-hook-plugin'),
13
+ Sass = require('sass'),
14
+ TimeFixPlugin = require('time-fix-plugin');
16
15
 
17
- export default {
16
+ module.exports = {
18
17
  target: 'web',
19
18
  mode: 'development',
20
19
  resolve: {
@@ -1,57 +1,54 @@
1
- import webpack from 'webpack';
2
- import TerserPlugin from 'terser-webpack-plugin';
3
- import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
4
- import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
5
-
6
- const productionConfig = {
7
- devtool: 'nosources-source-map',
8
- performance: {
9
- maxEntrypointSize: 300000,
10
- maxAssetSize: 250000,
11
- hints: 'warning',
12
- },
13
- mode: 'production',
14
- optimization: {
15
- splitChunks: false,
16
- runtimeChunk: false,
17
- minimizer: [
18
- new CssMinimizerPlugin({
19
- minimizerOptions: {
20
- preset: [
21
- "default",
22
- {
23
- zIndex: false,
24
- discardComments: { removeAll: true }
1
+ const webpack = require('webpack'),
2
+ TerserPlugin = require('terser-webpack-plugin'),
3
+ CssMinimizerPlugin = require('css-minimizer-webpack-plugin'),
4
+ RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts'),
5
+ productionConfig = {
6
+ devtool: 'nosources-source-map',
7
+ performance: {
8
+ maxEntrypointSize: 300000,
9
+ maxAssetSize: 250000,
10
+ hints: 'warning',
11
+ },
12
+ mode: 'production',
13
+ optimization: {
14
+ splitChunks: false,
15
+ runtimeChunk: false,
16
+ minimizer: [
17
+ new CssMinimizerPlugin({
18
+ minimizerOptions: {
19
+ preset: [
20
+ "default",
21
+ {
22
+ zIndex: false,
23
+ discardComments: { removeAll: true }
24
+ },
25
+ ],
26
+ },
27
+ minify: [
28
+ CssMinimizerPlugin.cssnanoMinify,
29
+ ]
30
+ }),
31
+ new TerserPlugin({
32
+ minify: TerserPlugin.swcMinify,
33
+ terserOptions: {
34
+ compress: {
35
+ drop_console: true,
25
36
  },
26
- ],
27
- },
28
- minify: [
29
- CssMinimizerPlugin.cssnanoMinify,
30
- ]
31
- }),
32
- new TerserPlugin({
33
- minify: TerserPlugin.swcMinify,
34
- terserOptions: {
35
- compress: {
36
- drop_console: true,
37
37
  },
38
+ parallel: true,
39
+ extractComments: false,
40
+ }),
41
+ ],
42
+ },
43
+ plugins: [
44
+ new webpack.DefinePlugin({
45
+ 'process.env': {
46
+ NODE_ENV: '"production"',
38
47
  },
39
- parallel: true,
40
- extractComments: false,
41
48
  }),
49
+ new RemoveEmptyScriptsPlugin(),
42
50
  ],
43
- },
44
- plugins: [
45
- new webpack.DefinePlugin({
46
- 'process.env': {
47
- NODE_ENV: '"production"',
48
- },
49
- }),
50
- new RemoveEmptyScriptsPlugin(),
51
- ].concat(
52
- []
53
- ),
54
- stats: 'normal',
55
- };
51
+ stats: 'normal',
52
+ };
56
53
 
57
- export default productionConfig;
54
+ module.exports = productionConfig;
@@ -1,75 +1,79 @@
1
- import config from './config.js';
2
- import Path from 'path';
3
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
4
- import * as ChangeCase from 'change-case';
5
- import Consola from 'consola';
6
- import Sw6PluginMapEmitterPlugin from '@pixolith/webpack-sw6-plugin-map-emitter';
7
- import Entry from 'webpack-glob-entry';
8
- import SvgStorePlugin from '@pixolith/external-svg-sprite-loader';
9
- import browserList from 'browserslist';
1
+ const config = require('./config');
10
2
 
11
- const outputConfig = {
12
- path: config.outputPath,
13
- publicPath: config.assetUrl,
14
- chunkFilename: (chunkData) => {
15
- return `js/chunk[name]${config.isProd ? '.[contenthash]' : ''}.js`;
3
+ const Path = require('path'),
4
+ MiniCssExtractPlugin = require('mini-css-extract-plugin'),
5
+ ChangeCase = require('change-case'),
6
+ Consola = require('consola'),
7
+ Sw6PluginMapEmitterPlugin = require('@pixolith/webpack-sw6-plugin-map-emitter'),
8
+ Entry = require('webpack-glob-entry'),
9
+ SvgStorePlugin = require('@pixolith/external-svg-sprite-loader'),
10
+ outputConfig = {
11
+ path: config.outputPath,
12
+ publicPath: config.assetUrl,
13
+ chunkFilename: (chunkData) => {
14
+ return `js/chunk[name]${
15
+ config.isProd ? '.[contenthash]' : ''
16
+ }.js`;
17
+ },
18
+ filename: (chunkData) => {
19
+ return `js/${chunkData.chunk.name.toLowerCase()}${
20
+ config.isProd ? `.[contenthash]` : ''
21
+ }.js`;
22
+ },
16
23
  },
17
- filename: (chunkData) => {
18
- return `js/${chunkData.chunk.name.toLowerCase()}${config.isProd ? `.[contenthash]` : ''}.js`;
19
- },
20
- };
24
+ miniCssChunksConfig = {
25
+ filename: `css/[name]${
26
+ config.isProd ? '.[contenthash]' : ''
27
+ }.css`,
28
+ chunkFilename: `css/[name].vendor${
29
+ config.isProd ? '.[contenthash]' : ''
30
+ }.css`
31
+ };
21
32
 
22
- const miniCssChunksConfig = {
23
- filename: `css/[name]${config.isProd ? '.[contenthash]' : ''}.css`,
24
- chunkFilename: `css/[name].vendor${config.isProd ? '.[contenthash]' : ''}.css`
25
- };
26
-
27
- export default {
33
+ module.exports = {
28
34
  entry: () => {
29
35
  let entriesPlugins = Entry(
30
- (filePath) => ChangeCase.kebabCase(filePath.match(config.pluginMatch)[1]),
31
- Path.resolve(config.pluginSrcPath, 'index.js')
36
+ (filePath) =>
37
+ ChangeCase.kebabCase(
38
+ filePath.match(config.pluginMatch)[1],
39
+ ),
40
+ Path.resolve(config.pluginSrcPath, 'index.js'),
32
41
  );
33
42
 
34
43
  let entriesVendor = Entry(
35
- (filePath) => ChangeCase.kebabCase(filePath.match(config.vendorMatch)[1]),
36
- Path.resolve(config.vendorSrcPath, 'index.js')
44
+ (filePath) =>
45
+ ChangeCase.kebabCase(
46
+ filePath.match(config.vendorMatch)[1],
47
+ ),
48
+ Path.resolve(config.vendorSrcPath, 'index.js'),
37
49
  );
38
50
 
39
51
  let routeSplitEntriesPlugins = Entry(
40
52
  (filePath) => filePath.split('/').pop().replace('.index.scss', '').replace('.', '_'),
41
- Path.resolve(config.pluginRouteSplitPath, '*index.scss')
53
+ Path.resolve(config.pluginRouteSplitPath, '*index.scss'),
42
54
  );
43
-
44
55
  let routeSplitEntriesVendor = Entry(
45
- (filePath) => ChangeCase.paramCase(filePath.match(config.vendorMatch)[1]),
46
- Path.resolve(config.vendorRouteSplitPath, 'route-splitting/*/*index.scss')
56
+ (filePath) =>
57
+ ChangeCase.paramCase(
58
+ filePath.match(config.vendorMatch)[1],
59
+ ),
60
+ Path.resolve(config.vendorRouteSplitPath, 'route-splitting/*/*index.scss'),
47
61
  );
48
62
 
49
- //let coreEntries = Entry(
50
- // (filePath) => 'storefront',
51
- // Path.resolve('vendor/shopware/storefront/Resources/app/storefront/src/scss', 'base.scss')
52
- //);
53
-
54
- //let match = new RegExp(`vendor\/store.shopware.com\/([\\w-]*)\/`);
55
- //let pluginEntries = Entry(
56
- // (filePath) => filePath.match(match)[1].toLowerCase(),
57
- // Path.resolve('vendor/store.shopware.com/*/src/Resources/app/storefront/src/scss', 'base.scss')
58
- //);
59
-
60
63
  if (config.isDebug) {
61
64
  Consola.info('[DEBUG]: Webpack entry points:');
62
- console.table({...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor});
65
+ console.table({ ...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor });
63
66
  }
64
67
 
65
- //return {...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor, ...coreEntries, ...pluginEntries};
66
- return {...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor};
68
+ return { ...entriesPlugins, ...entriesVendor, ...routeSplitEntriesPlugins, ...routeSplitEntriesVendor };
67
69
  },
68
70
  module: {
69
71
  rules: [
70
72
  {
71
73
  test: /\.js$/,
72
- exclude: (file) => /node_modules/.test(file),
74
+ exclude: (file) => {
75
+ return /node_modules/.test(file);
76
+ },
73
77
  use: [
74
78
  {
75
79
  loader: 'swc-loader',
@@ -78,7 +82,7 @@ export default {
78
82
  mode: 'entry',
79
83
  coreJs: '3.34.0',
80
84
  // .browserlist settings are not found by swc-loader, so we load it manually: https://github.com/swc-project/swc/issues/3365
81
- targets: browserList.loadConfig({
85
+ targets: require('browserslist').loadConfig({
82
86
  config: './package.json',
83
87
  }),
84
88
  },
@@ -157,7 +161,9 @@ export default {
157
161
  includes: ['js', 'css'],
158
162
  ignoreFiles: [/.*icons.*\.js/, /.*chunk.*\.js/],
159
163
  }),
164
+
160
165
  new SvgStorePlugin(),
166
+
161
167
  new MiniCssExtractPlugin(miniCssChunksConfig),
162
168
  ],
163
169
  };