Skip to content

Commit e112322

Browse files
refactor: drop webpack4
BREAKING CHANGE: minimum supported `webpack` version is `5.1`
2 parents a390616 + 4ec0d0d commit e112322

Some content is hidden

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

60 files changed

+2265
-5232
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
3+
extends: ["@webpack-contrib/eslint-config-webpack", "prettier"],
44
};

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
os: [ubuntu-latest, windows-latest, macos-latest]
5858
node-version: [10.x, 12.x, 14.x]
59-
webpack-version: [4, latest]
59+
webpack-version: [latest]
6060

6161
runs-on: ${{ matrix.os }}
6262

.prettierrc.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 7 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Then add the plugin to your `webpack` configuration. For example:
2929
**webpack.config.js**
3030

3131
```js
32-
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin');
33-
const CopyPlugin = require('copy-webpack-plugin');
32+
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
33+
const CopyPlugin = require("copy-webpack-plugin");
3434

3535
module.exports = {
3636
module: {
@@ -39,9 +39,9 @@ module.exports = {
3939
test: /\.html$/i,
4040
use: [
4141
{
42-
loader: 'file-loader',
42+
loader: "file-loader",
4343
options: {
44-
name: '[name].[ext]',
44+
name: "[name].[ext]",
4545
},
4646
},
4747
],
@@ -52,8 +52,8 @@ module.exports = {
5252
new CopyPlugin({
5353
patterns: [
5454
{
55-
context: path.resolve(__dirname, 'dist'),
56-
from: './src/*.html',
55+
context: path.resolve(__dirname, "dist"),
56+
from: "./src/*.html",
5757
},
5858
],
5959
}),
@@ -139,98 +139,6 @@ module.exports = {
139139
};
140140
```
141141

142-
### `cache`
143-
144-
> ⚠ Ignored in webpack 5! Please use https://webpack.js.org/configuration/other-options/#cache.
145-
146-
Type: `Boolean|String`
147-
Default: `true`
148-
149-
Enable file caching.
150-
Default path to cache directory: `node_modules/.cache/html-minimizer-webpack-plugin`.
151-
152-
> ℹ️ If you use your own `minify` function please read the `minify` section for cache invalidation correctly.
153-
154-
#### `Boolean`
155-
156-
Enable/disable file caching.
157-
158-
**webpack.config.js**
159-
160-
```js
161-
module.exports = {
162-
optimization: {
163-
minimize: true,
164-
minimizer: [
165-
new HtmlMinimizerPlugin({
166-
cache: true,
167-
}),
168-
],
169-
},
170-
};
171-
```
172-
173-
#### `String`
174-
175-
Enable file caching and set path to cache directory.
176-
177-
**webpack.config.js**
178-
179-
```js
180-
module.exports = {
181-
optimization: {
182-
minimize: true,
183-
minimizer: [
184-
new HtmlMinimizerPlugin({
185-
cache: 'path/to/cache',
186-
}),
187-
],
188-
},
189-
};
190-
```
191-
192-
### `cacheKeys`
193-
194-
> ⚠ Ignored in webpack 5! Please use https://webpack.js.org/configuration/other-options/#cache.
195-
196-
Type: `Function<(defaultCacheKeys, file) -> Object>`
197-
Default: `defaultCacheKeys => defaultCacheKeys`
198-
199-
Allows you to override default cache keys.
200-
201-
Default cache keys:
202-
203-
```js
204-
({
205-
htmlMinimizer: require('html-minifier-terser/package.json').version, // html-minifier-terser version
206-
'html-minimizer-webpack-plugin': require('../package.json').version, // plugin version
207-
'html-minimizer-webpack-plugin-options': this.options, // plugin options
208-
nodeVersion: process.version, // Node.js version
209-
assetName: file, // asset path
210-
contentHash: crypto.createHash('md4').update(input).digest('hex'), // source file hash
211-
});
212-
```
213-
214-
**webpack.config.js**
215-
216-
```js
217-
module.exports = {
218-
optimization: {
219-
minimize: true,
220-
minimizer: [
221-
new HtmlMinimizerPlugin({
222-
cache: true,
223-
cacheKeys: (defaultCacheKeys, file) => {
224-
defaultCacheKeys.myCacheKey = 'myCacheKeyValue';
225-
226-
return defaultCacheKeys;
227-
},
228-
}),
229-
],
230-
},
231-
};
232-
```
233-
234142
### `parallel`
235143

236144
Type: `Boolean|Number`
@@ -302,7 +210,7 @@ module.exports = {
302210
collapseWhitespace: true,
303211
},
304212
minify: (data, minimizerOptions) => {
305-
const htmlMinifier = require('html-minifier-terser');
213+
const htmlMinifier = require("html-minifier-terser");
306214
const [[filename, input]] = Object.entries(data);
307215

308216
return htmlMinifier.minify(input, minimizerOptions);

babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ module.exports = (api) => {
77
return {
88
presets: [
99
[
10-
'@babel/preset-env',
10+
"@babel/preset-env",
1111
{
1212
targets: {
13-
node: '10.13.0',
13+
node: "10.13.0",
1414
},
1515
},
1616
],

commitlint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: ['@commitlint/config-conventional'],
2+
extends: ["@commitlint/config-conventional"],
33
};

husky.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
hooks: {
3-
'pre-commit': 'lint-staged',
4-
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
3+
"pre-commit": "lint-staged",
4+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
55
},
66
};

jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
2-
testEnvironment: 'node',
3-
snapshotResolver: './test/helpers/snapshotResolver.js',
2+
testEnvironment: "node",
43
};

lint-staged.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
3-
'*.{json,md,yml,css,ts}': ['prettier --write', 'git add'],
2+
"*.js": ["eslint --fix", "prettier --write"],
3+
"*.{json,md,yml,css,ts}": ["prettier --write"],
44
};

0 commit comments

Comments
 (0)