@caweb/webpack 1.3.31 → 1.3.32

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caweb/html-webpack-plugin",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "CAWebPublishing Sample Page and Configurations",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -111,8 +111,7 @@
111
111
  "bootstrap-forced-colors-css": "^1.0.7",
112
112
  "chalk": "^5.4.1",
113
113
  "cross-spawn": "^7.0.6",
114
- "fast-xml-parser": "^5.0.9",
115
- "mini-css-extract-plugin": "^2.9.2"
114
+ "fast-xml-parser": "^5.0.9"
116
115
  },
117
116
  "dependencies": {
118
117
  "@caweb/a11y-webpack-plugin": "^1.0.9",
@@ -124,8 +123,10 @@
124
123
  "html-webpack-link-type-plugin": "^1.1.1",
125
124
  "html-webpack-plugin": "^5.6.3",
126
125
  "html-webpack-skip-assets-plugin": "^1.0.4",
126
+ "mini-css-extract-plugin": "^2.9.2",
127
127
  "rtlcss-webpack-plugin": "^4.0.7",
128
128
  "webpack": "^5.98.0",
129
- "webpack-cli": "^6.0.1"
129
+ "webpack-cli": "^6.0.1",
130
+ "webpack-remove-empty-scripts": "^1.0.4"
130
131
  }
131
- }
132
+ }
@@ -20,6 +20,7 @@ import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
20
20
  import RtlCssPlugin from 'rtlcss-webpack-plugin';
21
21
  import {HtmlWebpackSkipAssetsPlugin} from 'html-webpack-skip-assets-plugin';
22
22
  import {HtmlWebpackLinkTypePlugin} from 'html-webpack-link-type-plugin';
23
+ import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
23
24
 
24
25
  import JSHintPlugin from '@caweb/jshint-webpack-plugin';
25
26
  import CSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
@@ -110,19 +111,33 @@ let webpackConfig = {
110
111
  mode,
111
112
  name: 'uncompressed',
112
113
  target: 'web',
114
+ // Turn off caching of generated modules and chunks.
115
+ // @see https://webpack.js.org/configuration/cache/
113
116
  cache: false,
117
+
114
118
  stats: 'errors',
119
+
120
+ // Determine where the created bundles will be outputted.
121
+ // @see https://webpack.js.org/concepts/#output
115
122
  output: {
116
123
  ...baseConfig.output,
117
124
  clean: mode === 'production',
118
125
  pathinfo: false
119
126
  },
127
+
120
128
  performance: {
121
129
  maxAssetSize: 500000,
122
130
  maxEntrypointSize: 500000
123
131
  },
132
+
133
+ // This option determine how different types of module within the project will be treated.
134
+ // @see https://webpack.js.org/configuration/module/
124
135
  module:{
125
136
  ...baseConfig.module,
137
+ // This option sets up loaders for webpack configuration.
138
+ // Loaders allow webpack to process various types because by default webpack only
139
+ // understand JavaScript and JSON files.
140
+ // @see https://webpack.js.org/concepts/#loaders
126
141
  rules: [
127
142
  ...baseConfig.module.rules,
128
143
  /**
@@ -176,6 +191,23 @@ let webpackConfig = {
176
191
  }
177
192
  ]
178
193
  },
194
+ // WordPress already enqueues scripts and makes them available
195
+ // in global scope so those scripts don't need to be included on the bundle. For webpack
196
+ // to recognize those files, the global variable needs to be registered as externals.
197
+ // These allows global variable listed below to be imported into the module.
198
+ // @see https://webpack.js.org/configuration/externals/#externals
199
+ externals: {
200
+ // Third party dependencies.
201
+ jquery: 'jQuery',
202
+ underscore: '_',
203
+ lodash: 'lodash',
204
+ react: ['vendor', 'React'],
205
+ 'react-dom': ['vendor', 'ReactDOM'],
206
+
207
+ // WordPress dependencies.
208
+ '@wordpress/hooks': ['vendor', 'wp', 'hooks'],
209
+
210
+ },
179
211
  };
180
212
 
181
213
  /**
@@ -325,4 +357,8 @@ if( mode === 'production' ){
325
357
  )
326
358
  }
327
359
 
360
+ // we remove empty scripts
361
+ webpackConfig.plugins.push(
362
+ new RemoveEmptyScriptsPlugin()
363
+ );
328
364
  export default webpackConfig;