@henderea/static-site-builder 1.11.35 → 1.12.1

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.
@@ -11,6 +11,7 @@ import getClientEnvironment from './env.js';
11
11
  import * as paths from './paths.js';
12
12
  import _ from 'lodash';
13
13
  import { createRequire } from 'module';
14
+ import chalk from 'chalk';
14
15
 
15
16
  const require = createRequire(import.meta.url);
16
17
 
@@ -30,7 +31,7 @@ let env = getClientEnvironment(publicUrl);
30
31
  let ssbConfig = {};
31
32
 
32
33
  if(fs.existsSync(paths.ssbConfig)) {
33
- let ssbConfigObj = require(paths.ssbConfig);
34
+ const ssbConfigObj = require(paths.ssbConfig);
34
35
  if(ssbConfigObj) {
35
36
  if(_.isFunction(ssbConfigObj)) {
36
37
  ssbConfig = ssbConfigObj(env.raw, 'development', { publicUrl, ...paths });
@@ -70,6 +71,11 @@ if(ssbConfig.htmlWebpackPluginOptions && _.isPlainObject(ssbConfig.htmlWebpackPl
70
71
  htmlWebpackPluginOptions = _.extend({}, htmlWebpackPluginOptions, ssbConfig.htmlWebpackPluginOptions);
71
72
  }
72
73
 
74
+ function box(text, boxFormat, textFormat) {
75
+ const border = boxFormat(`+-${'-'.repeat(text.length)}-+`);
76
+ return `${border}\n${boxFormat('| ')}${textFormat(text)}${boxFormat(' |')}\n${border}`;
77
+ }
78
+
73
79
  const plugins = [
74
80
  new webpack.DefinePlugin(env.stringified),
75
81
  new HtmlWebpackPlugin(htmlWebpackPluginOptions),
@@ -78,6 +84,22 @@ const plugins = [
78
84
  fileName: 'asset-manifest.json',
79
85
  publicPath: publicPath
80
86
  }),
87
+ {
88
+ apply(compiler) {
89
+ const bld = chalk.bold;
90
+ const bgr = chalk.bold.green;
91
+ let first = true;
92
+ // Taps into the watchRun hook which fires when a watch build begins
93
+ compiler.hooks.watchRun.tap('WatchStartLoggerPlugin', () => {
94
+ if(first) {
95
+ first = false;
96
+ console.log(`\n${box('Starting initial build...', bld, bgr)}\n`);
97
+ return;
98
+ }
99
+ console.log(`\n${box('File change detected. Starting new build...', bld, bgr)}\n`);
100
+ });
101
+ }
102
+ },
81
103
  ];
82
104
 
83
105
  if(ssbConfig.plugins && _.isArray(ssbConfig.plugins)) {
@@ -259,7 +281,7 @@ export default _.defaultsDeep({}, ssbConfig.webpack || {}, {
259
281
  {
260
282
  loader: require.resolve('sass-loader'),
261
283
  options: {
262
- implementation: require.resolve('sass'),
284
+ implementation: require('sass'),
263
285
  sourceMap: true
264
286
  }
265
287
  }
@@ -21,14 +21,14 @@ const require = createRequire(import.meta.url);
21
21
 
22
22
  // Webpack uses `publicPath` to determine where the app is being served from.
23
23
  // It requires a trailing slash, or the file assets will get an incorrect path.
24
- let publicPath = paths.servedPath;
24
+ const publicPath = paths.servedPath;
25
25
  // Some apps do not use client-side routing with pushState.
26
26
  // For these, "homepage" can be set to "." to enable relative asset paths.
27
27
  // const shouldUseRelativeAssetPaths = publicPath === './';
28
28
  // `publicUrl` is just like `publicPath`, but we will provide it to our app
29
29
  // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
30
30
  // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
31
- let publicUrl = publicPath.slice(0, -1);
31
+ const publicUrl = publicPath.slice(0, -1);
32
32
 
33
33
  let env = getClientEnvironment(publicUrl);
34
34
 
@@ -45,7 +45,7 @@ if(fs.existsSync(paths.publicDir)) {
45
45
  let ssbConfig = {};
46
46
 
47
47
  if(fs.existsSync(paths.ssbConfig)) {
48
- let ssbConfigObj = require(paths.ssbConfig);
48
+ const ssbConfigObj = require(paths.ssbConfig);
49
49
  if(ssbConfigObj) {
50
50
  if(_.isFunction(ssbConfigObj)) {
51
51
  ssbConfig = ssbConfigObj(env.raw, 'production', { publicUrl, ...paths });
@@ -206,14 +206,14 @@ const getSizeValue = (val) => {
206
206
  if(_.isNil(val) || val === false) { return null; }
207
207
  if(_.isNumber(val) && !_.isNaN(val)) { return Math.round(val); }
208
208
  if(_.isString(val)) {
209
- let m = val.match(/^(\d+(?:\.\d+)?|\.\d+)([bkmg])?$/i);
209
+ const m = val.match(/^(\d+(?:\.\d+)?|\.\d+)([bkmg])?$/i);
210
210
  if(m) {
211
- let num = parseFloat(m[1]);
211
+ const num = parseFloat(m[1]);
212
212
  if(!_.isNaN(num)) {
213
213
  let unit = m[2];
214
214
  if(!unit || unit === '') { unit = 'b'; }
215
215
  unit = unit.toLowerCase();
216
- let unitIndex = 'bkmg'.indexOf(unit);
216
+ const unitIndex = 'bkmg'.indexOf(unit);
217
217
  if(unitIndex >= 0 || unitIndex <= 3) {
218
218
  return Math.round(num * Math.pow(1024, unitIndex));
219
219
  }
@@ -223,13 +223,13 @@ const getSizeValue = (val) => {
223
223
  return null;
224
224
  };
225
225
 
226
- let maxEntrypointSize = getSizeValue(config && config.maxEntrypointSize);
226
+ const maxEntrypointSize = getSizeValue(config && config.maxEntrypointSize);
227
227
 
228
228
  if(config && maxEntrypointSize) {
229
229
  performance.maxEntrypointSize = maxEntrypointSize;
230
230
  }
231
231
 
232
- let maxAssetSize = getSizeValue(config && config.maxAssetSize);
232
+ const maxAssetSize = getSizeValue(config && config.maxAssetSize);
233
233
 
234
234
  if(config && maxAssetSize) {
235
235
  performance.maxAssetSize = maxAssetSize;
@@ -371,7 +371,7 @@ export default _.defaultsDeep({}, ssbConfig.webpack || {}, {
371
371
  sassOptions: {
372
372
  outputStyle: 'compressed'
373
373
  },
374
- implementation: require.resolve('sass'),
374
+ implementation: require('sass'),
375
375
  sourceMap: true
376
376
  }
377
377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henderea/static-site-builder",
3
- "version": "1.11.35",
3
+ "version": "1.12.1",
4
4
  "description": "A static site builder",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -29,16 +29,16 @@
29
29
  },
30
30
  "type": "module",
31
31
  "dependencies": {
32
- "@babel/core": "^7.29.0",
33
- "@babel/plugin-transform-runtime": "^7.29.0",
34
- "@babel/preset-env": "^7.29.5",
32
+ "@babel/core": "^7.29.7",
33
+ "@babel/plugin-transform-runtime": "^7.29.7",
34
+ "@babel/preset-env": "^7.29.7",
35
35
  "babel-loader": "^10.1.1",
36
36
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
37
37
  "chalk": "^5.6.2",
38
38
  "copy-webpack-plugin": "^14.0.0",
39
39
  "cross-spawn": "^7.0.6",
40
40
  "css-loader": "^7.1.4",
41
- "cssnano": "^8.0.0",
41
+ "cssnano": "^8.0.1",
42
42
  "dotenv": "^17.4.2",
43
43
  "dotenv-expand": "^13.0.0",
44
44
  "ejs": "^5.0.2",
@@ -54,29 +54,32 @@
54
54
  "moment": "^2.30.1",
55
55
  "moment-locales-webpack-plugin": "^1.2.0",
56
56
  "postcss-loader": "^8.2.1",
57
- "postcss-preset-env": "^11.2.1",
57
+ "postcss-preset-env": "^11.3.0",
58
58
  "recursive-readdir": "^2.2.3",
59
- "sass": "^1.99.0",
60
- "sass-loader": "^16.0.8",
59
+ "sass": "^1.100.0",
60
+ "sass-loader": "^17.0.0",
61
61
  "strip-ansi": "^7.2.0",
62
62
  "style-loader": "^4.0.0",
63
- "terser-webpack-plugin": "^5.5.0",
63
+ "terser-webpack-plugin": "^5.6.1",
64
64
  "thread-loader": "^4.0.4",
65
- "ts-loader": "^9.5.7",
65
+ "ts-loader": "^9.6.0",
66
66
  "tsconfig-paths-webpack-plugin": "^4.2.0",
67
- "webpack": "^5.106.2",
67
+ "webpack": "^5.107.2",
68
68
  "webpack-manifest-plugin": "^6.0.1",
69
69
  "workbox-webpack-plugin": "^7.4.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@stylistic/eslint-plugin": "^5.10.0",
73
- "@typescript-eslint/eslint-plugin": "^8.59.2",
74
- "@typescript-eslint/parser": "^8.59.2",
73
+ "@typescript-eslint/eslint-plugin": "^8.60.1",
74
+ "@typescript-eslint/parser": "^8.60.1",
75
75
  "eslint": "^9.39.4",
76
- "eslint-config-henderea": "^2.0.124",
76
+ "eslint-config-henderea": "^2.0.125",
77
77
  "eslint-plugin-import": "^2.32.0",
78
78
  "globals": "^17.6.0",
79
79
  "typescript": "^6.0.3",
80
- "typescript-eslint": "^8.59.2"
80
+ "typescript-eslint": "^8.60.1"
81
+ },
82
+ "allowScripts": {
83
+ "@parcel/watcher@2.5.6": true
81
84
  }
82
85
  }
package/scripts/watch.js CHANGED
@@ -43,8 +43,12 @@ measureFileSizesBeforeBuild(paths.appBuild)
43
43
  // Start the webpack build
44
44
  return build(previousFileSizes,
45
45
  ({ stats, previousFileSizes, warnings }) => {
46
+ const startTime = stats.compilation.startTime;
47
+ const endTime = stats.compilation.endTime;
48
+ const totalDuration = endTime - startTime;
49
+ const durationDisplay = totalDuration < 1000 ? `${totalDuration} ms` : `${totalDuration / 1000.0} s`;
46
50
  if(warnings.length) {
47
- console.log(chalk.yellow('Compiled with warnings.\n'));
51
+ console.log(`${chalk.yellow('Compiled with warnings in')} ${chalk.bold(durationDisplay)}\n`);
48
52
  console.log(warnings.join('\n\n'));
49
53
  console.log(
50
54
  '\nSearch for the ' +
@@ -57,7 +61,7 @@ measureFileSizesBeforeBuild(paths.appBuild)
57
61
  ' to the line before.\n'
58
62
  );
59
63
  } else {
60
- console.log(chalk.green('Compiled successfully.\n'));
64
+ console.log(`${chalk.green('Compiled successfully in')} ${chalk.bold(durationDisplay)}\n`);
61
65
  }
62
66
 
63
67
  console.log('File sizes after gzip:\n');
@@ -83,7 +87,7 @@ measureFileSizesBeforeBuild(paths.appBuild)
83
87
 
84
88
  // Create the production build and print the deployment instructions.
85
89
  function build(previousFileSizes, resolve, reject) {
86
- let compiler = webpack(config);
90
+ const compiler = webpack(config);
87
91
  compiler.watch({}, (err, stats) => {
88
92
  if(err) {
89
93
  return reject(err);