@cley_faye/boilerplate 3.20.0 → 3.21.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/README.md CHANGED
@@ -166,6 +166,7 @@ The webpack options support a host of properties:
166
166
  - mode: The build mode. "development", "production" or "none"
167
167
  - defines: a record of value to define using Babel transform-define
168
168
  - resolve: a custom "resolve" object for webpack config
169
+ - generateReport: a boolean, set to true to generate a bundle size report HTML file
169
170
 
170
171
  ### SASS
171
172
  All `.sass` and `.scss` files in the `webres` directory will be processed as `.css` files
@@ -52,6 +52,7 @@ export interface WebpackOptions extends BaseOptions {
52
52
  babelPlugins?: Array<Record<string, unknown>>;
53
53
  defines?: Record<string, string>;
54
54
  resolve?: ResolveOptions;
55
+ generateReport?: boolean;
55
56
  typescript?: boolean;
56
57
  }
57
58
  /** Add a webpack task for the reactApp recipe
@@ -106,6 +107,9 @@ export interface WebpackOptions extends BaseOptions {
106
107
  * Build mode. "development", "production" or "none".
107
108
  * Defaults to "development"
108
109
  *
110
+ * @param [webpackOptions.generateReport]
111
+ * Generate a bundle report HTML file.
112
+ *
109
113
  * @param [webpackOptions.typescript]
110
114
  * Allow loading typescript source for webpack/babel.
111
115
  *
@@ -33,6 +33,7 @@ exports.handle = exports.webpackLoadersDefault = void 0;
33
33
  const path_1 = require("path");
34
34
  const node_fs_1 = require("node:fs");
35
35
  const eslint_webpack_plugin_1 = __importDefault(require("eslint-webpack-plugin"));
36
+ const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
36
37
  const util_js_1 = require("./util.js");
37
38
  const defaultCoreJS = 3;
38
39
  const eslintPlugin = () => new eslint_webpack_plugin_1.default({ cache: true });
@@ -178,6 +179,20 @@ const computeWebpackResolve = (webpackOptions) => {
178
179
  }
179
180
  return res;
180
181
  };
182
+ const getWebpackPlugins = (webpackOptions) => {
183
+ const plugins = [
184
+ eslintPlugin(),
185
+ ...webpackOptions.plugins ?? [],
186
+ ];
187
+ if (webpackOptions.generateReport) {
188
+ plugins.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
189
+ analyzerMode: "static",
190
+ reportFilename: (0, path_1.join)(process.cwd(), "bundle_report.html"),
191
+ openAnalyzer: false,
192
+ }));
193
+ }
194
+ return plugins;
195
+ };
181
196
  /** Add a webpack task for the reactApp recipe
182
197
  *
183
198
  * @param gruntConfig
@@ -230,6 +245,9 @@ const computeWebpackResolve = (webpackOptions) => {
230
245
  * Build mode. "development", "production" or "none".
231
246
  * Defaults to "development"
232
247
  *
248
+ * @param [webpackOptions.generateReport]
249
+ * Generate a bundle report HTML file.
250
+ *
233
251
  * @param [webpackOptions.typescript]
234
252
  * Allow loading typescript source for webpack/babel.
235
253
  *
@@ -257,10 +275,7 @@ const handle = (gruntConfig, targetName, webpackOptions) => {
257
275
  output: webpackOutput,
258
276
  externals: webpackOptions.externals,
259
277
  module: { rules: webpackLoaders },
260
- plugins: [
261
- eslintPlugin(),
262
- ...webpackOptions.plugins ?? [],
263
- ],
278
+ plugins: getWebpackPlugins(webpackOptions),
264
279
  resolve: webpackResolve,
265
280
  };
266
281
  // Special case: I'm not sure I can move options in the task-specific part of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cley_faye/boilerplate",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Boilerplate code generator for generic projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,14 +22,15 @@
22
22
  "homepage": "https://github.com/CleyFaye/boilerplate#readme",
23
23
  "devDependencies": {
24
24
  "@keeex/eslint-config": "^1.11.5",
25
- "@types/express": "^4.17.18",
25
+ "@types/express": "^4.17.19",
26
26
  "@types/grunt": "^0.4.28",
27
27
  "@types/http-errors": "^2.0.2",
28
28
  "@types/minimist": "^1.2.3",
29
- "@types/node": "^18.18.3",
30
- "@typescript-eslint/eslint-plugin": "^6.7.4",
31
- "@typescript-eslint/parser": "^6.7.4",
32
- "eslint": "^8.50.0",
29
+ "@types/node": "^18.18.4",
30
+ "@types/webpack-bundle-analyzer": "^4.6.1",
31
+ "@typescript-eslint/eslint-plugin": "^6.7.5",
32
+ "@typescript-eslint/parser": "^6.7.5",
33
+ "eslint": "^8.51.0",
33
34
  "eslint-plugin-deprecation": "^2.0.0",
34
35
  "eslint-plugin-import": "^2.28.1",
35
36
  "eslint-plugin-promise": "^6.1.1",
@@ -43,7 +44,7 @@
43
44
  "logform": "^2.5.1",
44
45
  "typescript": "^5.2.2",
45
46
  "webpack": "^5.88.2",
46
- "winston": "^3.10.0"
47
+ "winston": "^3.11.0"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "@babel/core": "7.x",
@@ -61,10 +62,11 @@
61
62
  "grunt-contrib-pug": "3.x",
62
63
  "grunt-contrib-watch": "1.x",
63
64
  "grunt-sass": "3.x",
64
- "grunt-webpack": "5.x",
65
+ "grunt-webpack": "5.x||6.x",
65
66
  "minimist": "^1.2.8",
66
67
  "sass": "1.x",
67
68
  "ts-loader": "^9.4.1",
69
+ "webpack-bundle-analyzer": "^4.9.1",
68
70
  "winston": "3.x"
69
71
  },
70
72
  "peerDependenciesMeta": {