Skip to content

Commit e30c8c4

Browse files
committed
release v4.0.0
1 parent 236e2ec commit e30c8c4

97 files changed

Lines changed: 1278 additions & 1396 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
# Change log
22

3-
## 4.0.0-beta.3 (2024-08-16)
4-
5-
- chore: code refactoring, invisible improvements, test this version with your projects
6-
7-
## 4.0.0-beta.2 (2024-08-15)
8-
9-
- fix: ERROR in RealContentHashPlugin in serv/watch mode after adding new import file
10-
11-
## 4.0.0-beta.1 (2024-08-13)
12-
13-
- fix: when using integrity occurs ERROR in RealContentHashPlugin in serv/watch mode after changes by using dynamic import
14-
15-
## 4.0.0-beta.0 (2024-08-10)
3+
<a id="v4-0-0" name="v4-0-0"></a>
4+
## 4.0.0 Release (24-09-08)
165

176
### BREAKING CHANGES
187

@@ -81,11 +70,11 @@
8170

8271
### DEPRECATIONS
8372

84-
- The `watchFiles.files` option has been renamed to `watchFiles.includes`.
73+
- The `watchFiles.files` option has been renamed to `watchFiles.includes`.\
8574
The `files` option is still supported but is deprecated.
8675
It's recommended to replace the `files` with `includes` in your config.
8776

88-
- The `watchFiles.ignore` option has been renamed to `watchFiles.excludes`.
77+
- The `watchFiles.ignore` option has been renamed to `watchFiles.excludes`.\
8978
The `ignore` option is still supported but is deprecated.
9079
It's recommended to replace the `ignore` with `excludes` in your config.
9180

@@ -133,16 +122,34 @@ module.exports = [
133122
module.exports = {
134123
name: 'client', // <= this name will displayed in console output
135124
}
136-
```
125+
```
126+
127+
### BUGFIX
128+
129+
- fix: ERROR in RealContentHashPlugin in serv/watch mode after adding new import file
130+
- fix: when using integrity occurs ERROR in RealContentHashPlugin in serv/watch mode after changes by using dynamic import
137131

138132
### MISC
139133

140134
- refactor: rewrite all static classes to regular, this is needed to support webpack multiple configurations
135+
- refactor: code refactoring, invisible improvements
141136
- test: add testing for Node.js `v22` on GitHub
142137
- test: add tests to improve the code coverage to 98%, 2% code can be tested only manual, e.g. in watch/serve mode after changes
143138
- chore: update dev packages, many packages requires Node.js >= v18
144139
- docs: update readme
145140

141+
## 4.0.0-beta.3 (2024-08-16)
142+
See release 4.0.0
143+
144+
## 4.0.0-beta.2 (2024-08-15)
145+
See release 4.0.0
146+
147+
## 4.0.0-beta.1 (2024-08-13)
148+
See release 4.0.0
149+
150+
## 4.0.0-beta.0 (2024-08-10)
151+
See release 4.0.0
152+
146153
## 3.17.3 (2024-08-09)
147154

148155
- fix: in dev mode imports SCSS in JS when in the same file is inlined another SCSS file via `?inline` query, #102

README.md

Lines changed: 99 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<div align="center">
2+
<img height="200" src="https://raw.githubusercontent.com/webdiscus/html-bundler-webpack-plugin/master/images/plugin-logo.png">
23
<h1 align="center">
3-
<img height="200" src="https://raw.githubusercontent.com/webdiscus/html-bundler-webpack-plugin/master/images/plugin-logo.png">
4-
<br>
54
<a href="https://github.com/webdiscus/html-bundler-webpack-plugin">HTML Bundler Plugin for Webpack</a>
65
</h1>
76
</div>
@@ -13,23 +12,64 @@
1312
[![codecov](https://codecov.io/gh/webdiscus/html-bundler-webpack-plugin/branch/master/graph/badge.svg?token=Q6YMEN536M)](https://codecov.io/gh/webdiscus/html-bundler-webpack-plugin)
1413
[![node](https://img.shields.io/npm/dm/html-bundler-webpack-plugin)](https://www.npmjs.com/package/html-bundler-webpack-plugin)
1514

15+
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+
<div align="center">
21+
📋 <a href="#contents">Table of Contents</a> 🚀 <a href="#install">Install and Quick Start</a> 🖼 <a href="#usage-examples">Usage examples</a> 🔆 <a href="#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:\
35+
[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).
36+
- **Source files** of [`script`](#option-js) and [`style`](#option-css) can be specified directly in HTML:
37+
- `<link href="./style.scss" rel="stylesheet">`\
38+
No longer need to define source style files in Webpack entry or import styles in JavaScript.
39+
- `<script src="./app.tsx" defer="defer"></script>`\
40+
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**:
42+
- `<link href="../images/favicon.svg" type="image/svg" rel=icon />`
43+
- `<img src="@images/pic.png" srcset="@images/pic400.png 1x, @images/pic800.png 2x" />`\
44+
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.
51+
52+
See [full list of features](#features).
53+
1654
## HTML template as entry point
1755

56+
<center>
57+
<img width="830" style="max-width: 100%;" src="https://raw.githubusercontent.com/webdiscus/html-bundler-webpack-plugin/master/images/assets-graph.png" alt="assets graph">
58+
</center>
59+
1860
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.
2163

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.
2365
The resolved assets will be processed via Webpack plugins/loaders and placed into the output directory.
2466
You can use a relative path or Webpack alias to a source file.
2567

2668
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.
2769

28-
This plugin is an **advanced replacement** of `html-webpack-plugin` and many other [plugins and loaders](#list-of-plugins).
29-
30-
<center>
31-
<img width="830" style="max-width: 100%;" src="https://raw.githubusercontent.com/webdiscus/html-bundler-webpack-plugin/master/images/assets-graph.png" alt="assets graph">
32-
</center>
70+
<!--
71+
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+
-->
3373

3474
For example, using source asset files is HTML template _./src/views/index.html_:
3575

@@ -51,8 +91,6 @@ For example, using source asset files is HTML template _./src/views/index.html_:
5191
</html>
5292
```
5393

54-
[Open an example in StackBlitz](https://stackblitz.com/edit/hello-world-webpack?file=webpack.config.js)
55-
5694
The folder structure of the example:
5795
```
5896
./src/views/index.html
@@ -78,13 +116,48 @@ src/
78116
-->
79117

80118

81-
All source file paths in dependencies will be resolved and auto-replaced with correct URLs in the bundled output.
119+
Simple and clear Webpack configuration:
120+
```js
121+
const path = require('path');
122+
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
82123

83-
---
124+
module.exports = {
125+
output: {
126+
path: path.resolve(__dirname, 'dist'),
127+
},
84128

85-
### 📋 [Table of Contents](#contents)
86-
### 🚀 [Install and Quick Start](#install)
87-
### 🖼 [Usage examples](#usage-examples)
129+
plugins: [
130+
new HtmlBundlerPlugin({
131+
// all the necessary options are in one place
132+
entry: {
133+
index: 'src/views/index.html', // save generated HTML into dist/index.html
134+
},
135+
js: {
136+
filename: 'js/[name].[contenthash:8].js', // JS output filename
137+
},
138+
css: {
139+
filename: 'css/[name].[contenthash:8].css', // CSS output filename
140+
},
141+
}),
142+
],
143+
144+
module: {
145+
rules: [
146+
{
147+
test: /\.s?css$/,
148+
use: ['css-loader', 'sass-loader'],
149+
},
150+
{
151+
test: /\.(ico|png|jp?g|svg)/,
152+
type: 'asset/resource',
153+
},
154+
],
155+
},
156+
};
157+
```
158+
See full list of all [plugin options](#toc-plugin-options).
159+
160+
[Open an example in StackBlitz](https://stackblitz.com/edit/hello-world-webpack?file=webpack.config.js)
88161

89162
---
90163
> 🦖 **Mozilla** already uses this plugin to build static HTML files for the [Mozilla AI GUIDE](https://github.com/mozilla/ai-guide) site.
@@ -94,30 +167,6 @@ All source file paths in dependencies will be resolved and auto-replaced with co
94167
---
95168

96169

97-
## 💡 Highlights
98-
99-
- An [entry point](#option-entry) is any HTML template.
100-
- **Auto processing** multiple HTML templates in the [entry path](#option-entry-path).
101-
- Allows to specify [`script`](#option-js) and [`style`](#option-css) **source files** directly in **HTML**:
102-
- `<link href="./style.scss" rel="stylesheet">`
103-
- `<script src="./app.tsx" defer="defer"></script>`
104-
- **Resolves** [source files](#loader-option-sources) in [default attributes](#loader-option-sources-default) `href` `src` `srcset` etc. using **relative path** or **alias**:
105-
- `<link href="../images/favicon.svg" type="image/svg" rel=icon />`
106-
- `<img src="@images/pic.png" srcset="@images/pic400.png 1x, @images/pic800.png 2x" />`
107-
- **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-
121170
## ❤️ Sponsors & Patrons
122171

123172
Thank you to all our sponsors and patrons!
@@ -142,19 +191,6 @@ See [how the plugin works under the hood](#plugin-hooks-and-callbacks).
142191

143192
<img width="830" style="max-width: 100%;" src="https://raw.githubusercontent.com/webdiscus/html-bundler-webpack-plugin/master/images/workflow.png">
144193

145-
## ✅ Profit
146-
147-
- **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-
158194
## ❓Question / Feature Request / Bug
159195

160196
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
167203
- [Use a HTML file as an entry point?](https://github.com/webpack/webpack/issues/536) (Webpack issue, #536)
168204
- [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_)
169205

206+
<a id="whats-new" name="whats-new"></a>
207+
170208
## 🔆 What's New in v4
171209

172210
- **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).
173214

174215
## 🔆 What's New in v3
175216

@@ -412,6 +453,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
412453
- [beforeEmit](#hook-beforeEmit)
413454
- [afterEmit](#hook-afterEmit)
414455
- [integrityHashes](#hook-integrity-hashes)
456+
<a id="toc-plugin-options" name="toc-plugin-options"></a>
415457
1. [Plugin options](#plugin-options)
416458
- [test](#option-test) (RegEx to handle matching templates)
417459
- [entry](#option-entry) (template as entry point)
@@ -440,6 +482,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
440482
- [hotUpdate](#option-hot-update)
441483
- [verbose](#option-verbose)
442484
- [loaderOptions](#option-loader-options) (reference to loader options)
485+
<a id="toc-loader-options" name="toc-loader-options"></a>
443486
1. [Loader options](#loader-options)
444487
- [sources](#loader-option-sources) (processing of custom tag attributes)
445488
- [root](#loader-option-root) (allow to resolve root path in attributes)
@@ -2904,9 +2947,9 @@ By default, resolves source files in the following tags and attributes:
29042947
>
29052948
> - `src="https://example.com/img/image.png"`
29062949
> - `src="//example.com/img/image.png"`
2907-
> - `src="/img/image.png"`
2950+
> - `src="/img/image.png"` (not processed only if not defined the [root option](#loader-option-root))
29082951
>
2909-
> Others not file values are ignored, e.g.:
2952+
> Others not filename values are ignored, e.g.:
29102953
>
29112954
> - `src="data:image/png; ..."`
29122955
> - `src="javascript: ..."`

0 commit comments

Comments
 (0)