@@ -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
3535module .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
236144Type: ` 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);
0 commit comments