html-bundle 5.5.2 → 6.0.0-beta

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
@@ -1,6 +1,16 @@
1
1
  # html-bundle
2
2
 
3
- > A very simple zero-config bundler primarily for HTML files. The idea is to use HTML as Single File Components, because HTML can already include `<style>` and `<script>` elements. Additionally, `TypeScript` and `JSX` can be used as inline or referenced script in HTML.
3
+ A (primarily) zero-config bundler for HTML files. The idea is to use HTML as Single File Components, because HTML can already include `<style>` and `<script>` elements.
4
+
5
+ ## Features
6
+
7
+ - 🦾 TypeScript (reference it as .js or write inline TS)
8
+ - 📦 Automatic Package Installation
9
+ - 💨 HMR
10
+ - ⚡ [ESBuild](https://github.com/evanw/esbuild)
11
+ - 🦔 [Critical CSS](https://github.com/evanw/esbuild)
12
+ - 💅 PostCSS and Tailwind CSS Support
13
+ - 🛡️ Almost no need to restart
4
14
 
5
15
  ![Demo](./example.gif)
6
16
 
@@ -20,19 +30,7 @@ Add an entry to script in package.json (see flags below).
20
30
  }
21
31
  ```
22
32
 
23
- or ideally
24
-
25
- ```json
26
- {
27
- "scripts": {
28
- "dev": "html-bundle --hmr --secure",
29
- "build": "html-bundle --critical",
30
- "serve": "html-bundle --serveOnly --secure"
31
- }
32
- }
33
- ```
34
-
35
- Add a `postcss.config.cjs` file and run the build command.
33
+ Add a `postcss.config.js` file and run the build command.
36
34
  <em>If you do not create this config file, a minimal in-memory config file will be created with `cssnano` as plugin.</em>
37
35
 
38
36
  ```properties
@@ -41,22 +39,33 @@ $ npm run build
41
39
 
42
40
  ## CLI
43
41
 
44
- `--serveOnly`: boots up a static server for the build folder (fastify)<br>
42
+ `--hmr`: boots up a static server and enables Hot Module Replacement. **This generates a development build.**<br>
45
43
  `--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>
46
- `--hmr`: boots up a static server and enables Hot Module Replacement. This works at its best with non-root HTML files without file references.<br>
47
- `--critical`: uses [critical](https://www.npmjs.com/package/critical) to extract and inline critical-path CSS to HTML.<br>
48
- `--csp`: disables inline option from `critical`.
44
+ `--critical`: uses critical to extract and inline critical-path CSS to HTML.<br>
45
+ `--handler`: path to your custom handler. Here, you can handle all non-supported files. You can get the filename via `process.argv[2]`.
46
+
47
+ ## Optional Config
48
+
49
+ _The CLI flags can also be set by the config. Flags set by the CLI will override the config._
50
+ Generate the config in the root and call it "bundle.config.js"
51
+
52
+ **src:** input path. Default to "src"<br>
53
+ **build:** output path. Defaults to "build"<br>
54
+ **port:** For the HMR Server. Defaults to 5000<br>
55
+ **esbuild:** Your additional config<br>
56
+ **html-minifier-terser:** Your additional config<br>
57
+ **critical:** Your additional config<br>
49
58
 
50
59
  ## Concept
51
60
 
52
- The bundler always globs all HTML, CSS and TS/JS files from the `src/` directory and processes them to the `build/` directory. PostCSS is being used for CSS files and inline styles, html-minifier for HTML and esbuild to bundle, minify, etc. for inline and referenced TS/JS. There are no <strong>regexes</strong>, just <strong>AST</strong> transformations. Server-sent events and [hydro-js](https://github.com/Krutsch/hydro-js) are used for HMR.
61
+ 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. This will install hydro-js to your dependencies. In order to trigger SPA Routers, the popstate event is being triggered after HMR Operations.
53
62
 
54
63
  ## Example hydro-js
55
64
 
56
- Have a look at [hydro-starter](https://github.com/Krutsch/hydro-starter).<br>
65
+ Get the idea from [hydro-starter](https://github.com/Krutsch/hydro-starter).<br>
57
66
  Set `"jsxFactory": "h"` in `tsconfig.json` for JSX.
58
67
 
59
- #### Input
68
+ ### Input
60
69
 
61
70
  ```html
62
71
  <!DOCTYPE html>