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
|**[`preprocessor`](#preprocessor)**|`{Function}`|`undefined`| Allows pre-processing of content before handling |
69
-
|**[`minimize`](#minimize)**|`{Boolean\|Object}`|`true` in production mode, otherwise `false`| Tell `html-loader` to minimize HTML |
70
-
|**[`esModule`](#esmodule)**|`{Boolean}`|`true`| Enable/disable ES modules syntax |
65
+
-**[`sources`](#sources)**
66
+
-**[`preprocessor`](#preprocessor)**
67
+
-**[`minimize`](#minimize)**
68
+
-**[`esModule`](#esmodule)**
71
69
72
70
### `sources`
73
71
74
-
Type: `Boolean|Object`
72
+
Type:
73
+
74
+
```ts
75
+
typesources=
76
+
|boolean
77
+
| {
78
+
list?:Array<{
79
+
tag?:string;
80
+
attribute?:string;
81
+
type?:string;
82
+
filter?: (
83
+
tag:string,
84
+
attribute:string,
85
+
attributes:string,
86
+
resourcePath:string
87
+
) =>boolean;
88
+
}>;
89
+
urlFilter?: (
90
+
attribute:string,
91
+
value:string,
92
+
resourcePath:string
93
+
) =>boolean;
94
+
};
95
+
```
96
+
75
97
Default: `true`
76
98
77
99
By default every loadable attributes (for example - `<img src="image.png">`) is imported (`const img = require('./image.png')` or `import img from "./image.png""`).
@@ -102,7 +124,7 @@ Supported tags and attributes:
102
124
- the `content` attribute of the `meta` tag when the `name` attribute is `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config`, `twitter:image` or when the `property` attribute is `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:secure_url`, `og:video`, `og:video:secure_url`, `vk:image` or when the `itemprop` attribute is `image`, `logo`, `screenshot`, `thumbnailurl`, `contenturl`, `downloadurl`, `duringmedia`, `embedurl`, `installurl`, `layoutimage`
103
125
- the `icon-uri` value component in `content` attribute of the `meta` tag when the `name` attribute is `msapplication-task`
104
126
105
-
#### `Boolean`
127
+
#### `boolean`
106
128
107
129
The `true` value enables processing of all default elements and attributes, the `false` disable processing of all attributes.
108
130
@@ -125,7 +147,7 @@ module.exports = {
125
147
};
126
148
```
127
149
128
-
#### `Object`
150
+
#### `object`
129
151
130
152
Allows you to specify which tags and attributes to process, filter them, filter urls and process sources starts with `/`.
131
153
@@ -177,7 +199,22 @@ module.exports = {
177
199
178
200
#### `list`
179
201
180
-
Type: `Array`
202
+
Type:
203
+
204
+
```ts
205
+
typelist=Array<{
206
+
tag?:string;
207
+
attribute?:string;
208
+
type?:string;
209
+
filter?: (
210
+
tag:string,
211
+
attribute:string,
212
+
attributes:string,
213
+
resourcePath:string
214
+
) =>boolean;
215
+
}>;
216
+
```
217
+
181
218
Default: [supported tags and attributes](#sources).
182
219
183
220
Allows to setup which tags and attributes to process and how, and the ability to filter some of them.
@@ -366,7 +403,16 @@ module.exports = {
366
403
367
404
#### `urlFilter`
368
405
369
-
Type: `Function`
406
+
Type:
407
+
408
+
```ts
409
+
typeurlFilter= (
410
+
attribute:string,
411
+
value:string,
412
+
resourcePath:string
413
+
) =>boolean;
414
+
```
415
+
370
416
Default: `undefined`
371
417
372
418
Allow to filter urls. All filtered urls will not be resolved (left in the code as they were written).
@@ -402,7 +448,15 @@ module.exports = {
402
448
403
449
### `preprocessor`
404
450
405
-
Type: `Function`
451
+
Type:
452
+
453
+
```ts
454
+
typepreprocessor= (
455
+
content:string|Buffer,
456
+
loaderContext:LoaderContext
457
+
) =>HTMLElement;
458
+
```
459
+
406
460
Default: `undefined`
407
461
408
462
Allows pre-processing of content before handling.
@@ -418,9 +472,9 @@ Allows pre-processing of content before handling.
418
472
<div>
419
473
```
420
474
421
-
#### `Function`
475
+
#### `function`
422
476
423
-
You can set the `preprocessor` option as a `Function` instance.
477
+
You can set the `preprocessor` option as a `function` instance.
424
478
425
479
**webpack.config.js**
426
480
@@ -498,12 +552,30 @@ module.exports = {
498
552
499
553
### `minimize`
500
554
501
-
Type: `Boolean|Object`
555
+
Type:
556
+
557
+
```ts
558
+
typeminimize=
559
+
|boolean
560
+
| {
561
+
caseSensitive?:boolean;
562
+
collapseWhitespace?:boolean;
563
+
conservativeCollapse?:boolean;
564
+
keepClosingSlash?:boolean;
565
+
minifyCSS?:boolean;
566
+
minifyJS?:boolean;
567
+
removeComments?:boolean;
568
+
removeRedundantAttributes?:boolean;
569
+
removeScriptTypeAttributes?:boolean;
570
+
removeStyleLinkTypeAttributes?:boolean;
571
+
};
572
+
```
573
+
502
574
Default: `true` in production mode, otherwise `false`
503
575
504
576
Tell `html-loader` to minimize HTML.
505
577
506
-
#### `Boolean`
578
+
#### `boolean`
507
579
508
580
The enabled rules for minimizing by default are the following ones:
509
581
@@ -540,7 +612,7 @@ module.exports = {
540
612
};
541
613
```
542
614
543
-
#### `Object`
615
+
#### `object`
544
616
545
617
**webpack.config.js**
546
618
@@ -597,7 +669,12 @@ module.exports = {
597
669
598
670
### `esModule`
599
671
600
-
Type: `Boolean`
672
+
Type:
673
+
674
+
```ts
675
+
typeesModule=boolean;
676
+
```
677
+
601
678
Default: `true`
602
679
603
680
By default, `html-loader` generates JS modules that use the ES modules syntax.
0 commit comments