Skip to content

Commit 1aca813

Browse files
committed
release v4.0.0.beta.0
1 parent 72bd2c3 commit 1aca813

247 files changed

Lines changed: 5370 additions & 3053 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.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest]
18-
node-version: [16, 18, 20]
18+
node-version: [18, 20, 22]
1919

2020
runs-on: ${{ matrix.os }}
2121
steps:

CHANGELOG.md

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,146 @@
11
# Change log
22

3+
## 4.0.0-beta.0 (2024-08-10)
4+
5+
### BREAKING CHANGES
6+
7+
- Drop supporting for Node.js < `v18`.\
8+
The plugin works on the Node.js >= `v14.21.xx`, but we can't test the plugin with outdated Node.js versions,
9+
because many actual dev dependencies requires current LTS Node.js >= v18.x.
10+
Up-to-date versions of dependencies are very important because they contain `security updates`.
11+
12+
- The plugin `option` property is not static anymore:
13+
14+
OLD (up to v3.x)
15+
```js
16+
class MyPlugin extends HtmlBundlerPlugin {
17+
constructor(options = {}) {
18+
super({ ...options });
19+
}
20+
init(compiler) {
21+
// MyPlugin.option. ...; <= was as static property
22+
}
23+
}
24+
```
25+
NEW (since v4.0)
26+
```js
27+
class MyPlugin extends HtmlBundlerPlugin {
28+
constructor(options = {}) {
29+
super({ ...options });
30+
}
31+
init(compiler) {
32+
// this.option. ...; <= now is non static property
33+
}
34+
}
35+
```
36+
37+
- Using the `addProcess()` plugin method is changed:
38+
39+
OLD (up to v3.x)
40+
```js
41+
class MyPlugin extends HtmlBundlerPlugin {
42+
constructor(options = {}) {
43+
super({ ...options });
44+
}
45+
init(compiler) {
46+
// the method was as property of the static `option`
47+
MyPlugin.option.addProcess('postprocess', (content) => {
48+
return content;
49+
});
50+
}
51+
}
52+
```
53+
NEW (since v4.0)
54+
```js
55+
class MyPlugin extends HtmlBundlerPlugin {
56+
constructor(options = {}) {
57+
super({ ...options });
58+
}
59+
init(compiler) {
60+
// now is the class method
61+
this.addProcess('postprocess', (content) => {
62+
return content;
63+
});
64+
}
65+
}
66+
```
67+
68+
### DEPRECATIONS
69+
70+
- The `watchFiles.files` option has been renamed to `watchFiles.includes`.
71+
The `files` option is still supported but is deprecated.
72+
It's recommended to replace the `files` with `includes` in your config.
73+
74+
- The `watchFiles.ignore` option has been renamed to `watchFiles.excludes`.
75+
The `ignore` option is still supported but is deprecated.
76+
It's recommended to replace the `ignore` with `excludes` in your config.
77+
78+
79+
### FEATURES
80+
81+
- feat: add support the multiple webpack configuration:
82+
```js
83+
const path = require('path');
84+
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin');
85+
86+
module.exports = [
87+
{
88+
name: 'first',
89+
output: {
90+
path: path.join(__dirname, 'dist/web1/'),
91+
},
92+
plugins: [
93+
new HtmlBundlerPlugin({
94+
entry: {
95+
index: './web1/views/home.html',
96+
},
97+
}),
98+
],
99+
},
100+
101+
{
102+
name: 'second',
103+
output: {
104+
path: path.join(__dirname, 'dist/web2'),
105+
},
106+
plugins: [
107+
new HtmlBundlerPlugin({
108+
entry: {
109+
index: './web2/views/home.html',
110+
},
111+
}),
112+
],
113+
},
114+
];
115+
```
116+
117+
- feat: display webpack config name in console output:
118+
```js
119+
module.exports = {
120+
name: 'client', // <= this name will displayed in console output
121+
}
122+
```
123+
124+
### MISC
125+
126+
- refactor: rewrite all static classes to regular, this is needed to support webpack multiple configurations
127+
- test: add testing for Node.js `v22` on GitHub
128+
- 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
129+
- chore: update dev packages, many packages requires Node.js >= v18
130+
- docs: update readme
131+
132+
## 3.17.3 (2024-08-09)
133+
134+
- fix: in dev mode imports SCSS in JS when in the same file is inlined another SCSS file via `?inline` query, #102
135+
136+
## 3.17.2 (2024-08-08)
137+
138+
- fix: error when `integrity` option is enabled but no template defined in entry, #107
139+
140+
## 3.17.1 (2024-08-01)
141+
142+
- fix: when using the integrity option, leaves the original attributes in the script tag as is
143+
3144
## 3.17.0 (2024-07-23)
4145

5146
- feat: add support the `?inline` query for styles imported in JavaScript:
@@ -30,8 +171,18 @@
30171

31172
## 3.14.0 (2024-05-31)
32173

33-
- feat(Pug): add `watchFiles.includes` and `watchFiles.excludes` options to allow watch specifically external file,
174+
- feat: add `watchFiles.includes` and `watchFiles.excludes` options to allow watch specifically external file,
34175
e.g. *.md file included via Pug filter from any location outer project directory
176+
```ts
177+
type WatchFiles = {
178+
paths?: Array<string>;
179+
files?: Array<RegExp>;
180+
includes?: Array<RegExp | string>; // <= NEW
181+
ignore?: Array<RegExp>;
182+
excludes?: Array<RegExp | string>; // <= NEW
183+
};
184+
```
185+
WARNING: in the 4.0 version the undocumented `includes` and `excludes` properties are removed from code.
35186

36187
## 3.13.0 (2024-05-26)
37188

README.md

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ A template imported in JS will be compiled into [template function](#template-in
2727

2828
This plugin is an **advanced replacement** of `html-webpack-plugin` and many other [plugins and loaders](#list-of-plugins).
2929

30-
<!--
31-
<table align="center">
32-
<tr><th>Entry point is HTML</th></tr>
33-
<tr><td><pre>
34-
html <-- Start from HTML
35-
┌─────────┼────────┐
36-
css img js
37-
┌──┴──┐ ┌────┼────┐
38-
img font js css img
39-
</pre></td></tr>
40-
</table>
41-
-->
42-
4330
<center>
4431
<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">
4532
</center>
@@ -180,6 +167,10 @@ If you have discovered a bug or have a feature suggestion, feel free to create a
180167
- [Use a HTML file as an entry point?](https://github.com/webpack/webpack/issues/536) (Webpack issue, #536)
181168
- [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_)
182169

170+
## 🔆 What's New in v4
171+
172+
- **NEW** added supports the [multiple configurations](https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations)
173+
183174
## 🔆 What's New in v3
184175

185176
- **NEW** added supports the [template function](#template-in-js) in JS runtime on the client-side.
@@ -206,20 +197,6 @@ For full release notes see the [changelog](https://github.com/webdiscus/html-bun
206197
The current version works stable with `cache.type` as `'memory'` (Webpack's default setting).\
207198
Support for the `'filesystem'` cache type is experimental.
208199

209-
### Multiple config files
210-
211-
The multiple config files are not supported, because in some special use cases the Webpack API works not properly (all previous configurations are overridden by the latest configuration).
212-
213-
Instead of this:
214-
```
215-
npx webpack -c app1.config.js app2.config.js
216-
```
217-
you can use following:
218-
```
219-
npx webpack -c app1.config.js
220-
npx webpack -c app2.config.js
221-
```
222-
223200
---
224201

225202
<a id="install" name="install"></a>
@@ -267,7 +244,7 @@ For example, there is the template _./src/views/home.html_:
267244
```
268245

269246
All source filenames should be relative to the entrypoint template, or you can use [Webpack alias](https://webpack.js.org/configuration/resolve/#resolvealias).
270-
The references are rewritten in the generated HTML so that they link to the correct output files.
247+
The references are rewritten in the generated HTML so that they point to the correct output files.
271248

272249
The generated HTML contains URLs of the output filenames:
273250

@@ -2563,7 +2540,7 @@ or an array to specify multiple hash functions for compatibility with many brows
25632540
> - The [`output.crossOriginLoading`](https://webpack.js.org/configuration/output/#outputcrossoriginloading) Webpack option must be specified as `'use-credentials'` or `'anonymous'`.
25642541
> The bundler plugin adds the `crossorigin` attribute with the value defined in the `crossOriginLoading`.
25652542
> The `crossorigin` attribute tells the browser to request the script with CORS enabled, which is necessary because the integrity check fails without CORS.
2566-
> - The [`optimization.realContentHash`](https://webpack.js.org/configuration/optimization/#optimizationrealcontenthash) Webpack option must be enabled, is enabled by default in production mode only.
2543+
> - The [`optimization.realContentHash`](https://webpack.js.org/configuration/optimization/#optimizationrealcontenthash) Webpack option must be enabled, by default is enabled in production mode only.
25672544
>
25682545
> This requirement is necessary to avoid the case where the browser tries to load a contents of a file from the local cache since the filename has not changed, but the `integrity` value has changed on the server.
25692546
> In this case, the browser will not load the file because the `integrity` of the cached file computed by the browser will not match the `integrity` attribute computed on the server.
@@ -2651,8 +2628,8 @@ Type:
26512628
```ts
26522629
type WatchFiles = {
26532630
paths?: Array<string>;
2654-
files?: Array<RegExp>;
2655-
ignore?: Array<RegExp>;
2631+
includes?: Array<RegExp>;
2632+
excludes?: Array<RegExp>;
26562633
};
26572634
```
26582635
@@ -2661,13 +2638,13 @@ Default:
26612638
```js
26622639
watchFiles: {
26632640
paths: ['./src'],
2664-
files: [/\.(html|ejs|eta)$/],
2665-
ignore: [
2641+
includes: [/\.(html|ejs|eta)$/],
2642+
excludes: [
26662643
/[\\/](node_modules|dist|test)$/, // ignore standard project dirs
26672644
/[\\/]\..+$/, // ignore hidden dirs and files, e.g.: .git, .idea, .gitignore, etc.
2668-
/package(?:-lock)*\.json$/, // ingnore npm files
2645+
/package(?:-lock)*\.json$/, // ignore npm files
26692646
/webpack\.(.+)\.js$/, // ignore Webpack config files
2670-
/\.(je?pg|png|ico|webp|svg|woff2?|ttf|otf|eot)$/, // ignore binary assets
2647+
/\.(je?pg|png|ico|webp|svg|woff2?|ttf|otf|eot)$/, // exclude binary assets
26712648
],
26722649
}
26732650
```
@@ -2681,14 +2658,16 @@ Allows to configure paths and files to watch file changes for rebuild in `watch`
26812658
26822659
#### Properties:
26832660
2684-
- `paths` - A list of relative or absolute paths to directories where should be watched `files`.\
2661+
- `paths` - A list of relative or absolute paths to directories where should be watched `includes`.\
26852662
The watching path for each template defined in the entry will be autodetect as the first level subdirectory of the template relative to the project's root path.
26862663
E.g., the template `./src/views/index.html` has the watching path of `./src`.
26872664
2688-
- `files` - Watch the files specified in `paths`, except `ignore`, that match the regular expressions.
2665+
- `includes` - Watch the files specified in `paths`, except `excludes`, that match the regular expressions.
26892666
Defaults, are watched only files that match the [`test`](#option-test) plugin option.
26902667
2691-
- `ignore` - Ignore the specified paths or files, that match the regular expressions.
2668+
- `excludes` - Exclude the specified paths or files, that match the regular expressions.
2669+
2670+
This options does not override the default values, but extends them.
26922671
26932672
For example, all source files are in the `./src` directory,
26942673
while some partials included in a template are in `./vendor/` directory, then add it to the `paths`:
@@ -2700,19 +2679,19 @@ watchFiles: {
27002679
```
27012680
27022681
If you want watch changes in some special files used in your template that are only loaded through the template engine,
2703-
add them to the `files` property:
2682+
add them to the `includes` property:
27042683
27052684
```js
27062685
watchFiles: {
27072686
paths: ['vendor'],
2708-
files: [
2687+
includes: [
27092688
/data\.(js|json)$/,
27102689
],
27112690
},
27122691
```
27132692
2714-
To exclude watching of files defined in `paths` and `files`, you can use the `ignore` property.
2715-
This option has the prio over paths and files.
2693+
To exclude watching of files defined in `paths` and `includes`, you can use the `excludes` option.
2694+
This option has the priority over paths and files.
27162695
27172696
> **Note**
27182697
>

0 commit comments

Comments
 (0)