html-bundle 6.0.4 → 6.0.5
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 +2 -2
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
- package/src/bundle.mts +2 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ $ npm run build
|
|
|
47
47
|
|
|
48
48
|
`--hmr`: boots up a static server and enables Hot Module Replacement. **This generates a development build and works best when not triggered from the main index.html**<br>
|
|
49
49
|
`--secure`: creates a secure HTTP2 over HTTPS instance. This requires the files `localhost.pem` and `localhost-key.pem` in the root folder. You can generate them with [mkcert](https://github.com/FiloSottile/mkcert) for instance.<br>
|
|
50
|
-
`--
|
|
50
|
+
`--isCritical`: uses critical to extract and inline critical-path CSS to HTML.<br>
|
|
51
51
|
`--handler`: path to your custom handler. Here, you can handle all non-supported files. You can get the filename via `process.argv[2]`.
|
|
52
52
|
|
|
53
53
|
## Optional Config
|
|
@@ -65,7 +65,7 @@ Generate the config in the root and call it "bundle.config.js"
|
|
|
65
65
|
|
|
66
66
|
## Concept
|
|
67
67
|
|
|
68
|
-
The bundler always globs all HTML, CSS and TS/JS files from the `src` (config) directory and processes them to the `build` (config) directory. PostCSS is being used for CSS files and inline styles, html-minifier-terser for HTML and esbuild to bundle, minify, etc. for inline and referenced TS/JS. Server-sent events and [hydro-js](https://github.com/Krutsch/hydro-js) are used for HMR.
|
|
68
|
+
The bundler always globs all HTML, CSS and TS/JS files from the `src` (config) directory and processes them to the `build` (config) directory. PostCSS is being used for CSS files and inline styles, html-minifier-terser for HTML and esbuild to bundle, minify, etc. for inline and referenced TS/JS. Server-sent events and [hydro-js](https://github.com/Krutsch/hydro-js) are used for HMR. In order to trigger SPA Routers, the popstate event is being triggered after HMR Operations.
|
|
69
69
|
|
|
70
70
|
## Example hydro-js
|
|
71
71
|
|
package/dist/bundle.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { getTagName, findElements } from "@web/parse5-utils";
|
|
|
14
14
|
import awaitSpawn from "await-spawn";
|
|
15
15
|
import { fileCopy, createDefaultServer, getPostCSSConfig, getBuildPath, createDir, bundleConfig, serverSentEvents, addHMRCode, } from "./utils.mjs";
|
|
16
16
|
const isHMR = process.argv.includes("--hmr") || bundleConfig.hmr;
|
|
17
|
-
const isCritical = process.argv.includes("--
|
|
17
|
+
const isCritical = process.argv.includes("--isCritical") || bundleConfig.isCritical;
|
|
18
18
|
const isSecure = process.argv.includes("--secure") || bundleConfig.secure; // uses CSP for critical too
|
|
19
19
|
const handlerFile = process.argv.includes("--handler")
|
|
20
20
|
? process.argv[process.argv.indexOf("--handler") + 1]
|
package/package.json
CHANGED
package/src/bundle.mts
CHANGED
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
} from "./utils.mjs";
|
|
28
28
|
|
|
29
29
|
const isHMR = process.argv.includes("--hmr") || bundleConfig.hmr;
|
|
30
|
-
const isCritical =
|
|
30
|
+
const isCritical =
|
|
31
|
+
process.argv.includes("--isCritical") || bundleConfig.isCritical;
|
|
31
32
|
const isSecure = process.argv.includes("--secure") || bundleConfig.secure; // uses CSP for critical too
|
|
32
33
|
const handlerFile = process.argv.includes("--handler")
|
|
33
34
|
? process.argv[process.argv.indexOf("--handler") + 1]
|