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