You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generates output HTML, JS and CSS from templates containing source files of scripts, styles and other assets.\
16
+
Advanced alternative to [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) and modern replacement of many [plugins and loaders](#list-of-plugins).
17
+
18
+
---
19
+
20
+
<divalign="center">
21
+
📋 <ahref="#contents">Table of Contents</a> 🚀 <ahref="#install">Install and Quick Start</a> 🖼 <ahref="#usage-examples">Usage examples</a> 🔆 <ahref="#whats-new">What's New</a>
22
+
</div>
23
+
24
+
<!--
25
+
#### 📋 [Table of Contents](#contents) 🚀 [Install and Quick Start](#install) 🖼 [Usage examples](#usage-examples)
26
+
-->
27
+
28
+
---
29
+
30
+
## 💡 Highlights
31
+
32
+
-**Start from HTML**, not from JS. An [entry point](#option-entry) is any HTML template.
33
+
-**Auto processing** multiple HTML templates in the [entry path](#option-entry-path).
34
+
-**Renders** the most popular [template engines](#template-engine) "**out of the box**", without additional plugins and loaders:\
No longer need to define source JavaScript files in Webpack entry.
41
+
-**Resolves**[source files](#loader-option-sources) in [default attributes](#loader-option-sources-default)`href``src``srcset` using **relative path** or **alias**:
Source files will be resolved, processed and auto-replaced with correct URLs in the bundled output.
45
+
-**Inlines**[JS](#recipe-inline-js), [CSS](#recipe-inline-css) and [Images](#recipe-inline-image) into HTML. See [how to inline all resources](#recipe-inline-all-assets-to-html) into single HTML file.
46
+
- Generates the [preload](#option-preload) tags for fonts, images, video, scripts, styles.
47
+
- Generates the [integrity](#option-integrity) attribute in the `link` and `script` tags.
48
+
- Generates the [favicons](#favicons-bundler-plugin) of different sizes for various platforms.
49
+
- You can create **own plugin** using the [Plugin Hooks](#plugin-hooks-and-callbacks).
50
+
- Over 600 [tests](https://github.com/webdiscus/html-bundler-webpack-plugin/tree/master/test) for various use cases.
The **HTML Bundler** generates static HTML or [template function](#template-in-js) from [various templates](#template-engine) containing source files of scripts, styles, images, fonts and other resources, similar to how it works in [Vite](https://vitejs.dev/guide/#index-html-and-project-root).
19
-
This plugin looks at the template files in [entry](#option-entry) to start building the bundle.
20
-
The source files of dependencies (scripts, styles, etc.) can be defined directly in the template.
61
+
This plugin looks at the template files in [entry option](#option-entry) to start building the bundle.
62
+
The [source files](#loader-option-sources) of dependencies (scripts, styles, etc.) can be defined directly in the template.
21
63
22
-
The plugin resolves source files of assets in templates and replaces them with correct output URLs in the generated HTML.
64
+
The plugin **resolves source files** of assets in templates and replaces them with correct output URLs in the generated HTML.
23
65
The resolved assets will be processed via Webpack plugins/loaders and placed into the output directory.
24
66
You can use a relative path or Webpack alias to a source file.
25
67
26
68
A template imported in JS will be compiled into [template function](#template-in-js). You can use the **template function** in JS to render the template with variables in runtime on the client-side in the browser.
27
69
28
-
This plugin is an **advanced replacement** of `html-webpack-plugin` and many other [plugins and loaders](#list-of-plugins).
This plugin is an advanced replacement of [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) and many other [plugins and loaders](#list-of-plugins).
72
+
-->
33
73
34
74
For example, using source asset files is HTML template _./src/views/index.html_:
35
75
@@ -51,8 +91,6 @@ For example, using source asset files is HTML template _./src/views/index.html_:
51
91
</html>
52
92
```
53
93
54
-
[Open an example in StackBlitz](https://stackblitz.com/edit/hello-world-webpack?file=webpack.config.js)
55
-
56
94
The folder structure of the example:
57
95
```
58
96
./src/views/index.html
@@ -78,13 +116,48 @@ src/
78
116
-->
79
117
80
118
81
-
All source file paths in dependencies will be resolved and auto-replaced with correct URLs in the bundled output.
-**Resolves**[source files](#loader-option-sources) in [default attributes](#loader-option-sources-default)`href``src``srcset` etc. using **relative path** or **alias**:
-**Inlines**[JS](#recipe-inline-js) and [CSS](#recipe-inline-css) into HTML.
108
-
-**Inlines**[images](#recipe-inline-image) into HTML and CSS.
109
-
- Supports **styles** used in `*.vue` files.
110
-
-**Renders** the [template engines](#template-engine) such as [Eta](#using-template-eta), [EJS](#using-template-ejs), [Handlebars](#using-template-handlebars), [Nunjucks](#using-template-nunjucks), [Pug](#using-template-pug), [TwigJS](#using-template-twig), [LiquidJS](#using-template-liquidjs).
111
-
-**Compile** a template into [template function](#template-in-js) for usage in JS on the client-side.
112
-
- Generates the [preload](#option-preload) tags for fonts, images, video, scripts, styles, etc.
113
-
- Generates the [integrity](#option-integrity) attribute in the `link` and `script` tags.
114
-
- Generates the [favicons](#favicons-bundler-plugin) of different sizes for various platforms.
115
-
- You can create **own plugin** using the [Plugin Hooks](#plugin-hooks-and-callbacks).
116
-
- Over 600 [tests](https://github.com/webdiscus/html-bundler-webpack-plugin/tree/master/test).
117
-
118
-
See the [full list of features](#features).
119
-
120
-
121
170
## ❤️ Sponsors & Patrons
122
171
123
172
Thank you to all our sponsors and patrons!
@@ -142,19 +191,6 @@ See [how the plugin works under the hood](#plugin-hooks-and-callbacks).
-**Simplify Webpack config** using one powerful plugin instead of many [different plugins and loaders](#list-of-plugins).
148
-
149
-
-**Start from HTML**, not from JS. Define an HTML template file as an **entry point**.
150
-
151
-
- Specify script and style **source files** directly in a template,
152
-
and you no longer need to define them in Webpack entry or import styles in JavaScript.
153
-
154
-
- Use **any template engine** without additional plugins and loaders.
155
-
Most popular [template engines](#template-engine) supported "**out of the box**".
156
-
157
-
158
194
## ❓Question / Feature Request / Bug
159
195
160
196
If you have discovered a bug or have a feature suggestion, feel free to create an [issue](https://github.com/webdiscus/html-bundler-webpack-plugin/issues) on GitHub.
@@ -167,9 +203,14 @@ If you have discovered a bug or have a feature suggestion, feel free to create a
167
203
-[Use a HTML file as an entry point?](https://github.com/webpack/webpack/issues/536) (Webpack issue, #536)
168
204
-[Comparison and Benchmarks of Node.js libraries to colorize text in terminal](https://dev.to/webdiscus/comparison-of-nodejs-libraries-to-colorize-text-in-terminal-4j3a) (_offtopic_)
169
205
206
+
<aid="whats-new"name="whats-new"></a>
207
+
170
208
## 🔆 What's New in v4
171
209
172
210
-**NEW** added supports the [multiple configurations](https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations).
211
+
-**SUPPORTS** Node.js version `18+`
212
+
-**SUPPORTS** Webpack version `5.81+`
213
+
-**BREAKING CHANGES** see in the [changelog](https://github.com/webdiscus/html-bundler-webpack-plugin/blob/master/CHANGELOG.md#v4-0-0).
173
214
174
215
## 🔆 What's New in v3
175
216
@@ -412,6 +453,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
0 commit comments