File tree Expand file tree Collapse file tree 1 file changed +62
-3
lines changed Expand file tree Collapse file tree 1 file changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -241,7 +241,68 @@ module.exports = {
241
241
242
242
If the tag name is not specified it will process all the tags.
243
243
244
- > ⚠ You must specify the tag name if using ` ... ` to extend the default sources list
244
+ ** Note:** source with a ` tag ` option takes precedence over source without.
245
+
246
+ For example, to process ` data-src ` attributes on _ all_ tags, omit the tag name:
247
+
248
+ ** webpack.config.js**
249
+
250
+ ``` js
251
+ module .exports = {
252
+ module: {
253
+ rules: [
254
+ {
255
+ test: / \. html$ / i ,
256
+ loader: " html-loader" ,
257
+ options: {
258
+ sources: {
259
+ list: [
260
+ {
261
+ attribute: " data-src" ,
262
+ type: " src" ,
263
+ },
264
+ ],
265
+ },
266
+ },
267
+ },
268
+ ],
269
+ },
270
+ };
271
+ ```
272
+
273
+ > ⚠ You ** must** specify a tag name if using ` ... ` to extend attributes for tags already in the default sources list
274
+
275
+ For example, to extend the default source list so that it also processes ` data-src ` attributes on _ all_ tags, you might be tempted to do this:
276
+
277
+ ``` js
278
+ module .exports = {
279
+ module: {
280
+ rules: [
281
+ {
282
+ test: / \. html$ / i ,
283
+ loader: " html-loader" ,
284
+ options: {
285
+ sources: {
286
+ list: [
287
+ // All default supported tags and attributes
288
+ " ..." ,
289
+ {
290
+ attribute: " data-src" ,
291
+ type: " src" ,
292
+ },
293
+ ],
294
+ },
295
+ },
296
+ },
297
+ ],
298
+ },
299
+ };
300
+ ```
301
+
302
+ However this will only process ` data-src ` attributes on tags that _ aren't in the default list_ :
303
+
304
+ - ` <p data-src=".."> ` will be processed, as ` p ` is not in the default sources list
305
+ - ` <img data-src=".."> ` won't be processed, as ` img ` is already in the default sources list
245
306
246
307
> You can use your custom filter to specify html elements to be processed.
247
308
@@ -322,8 +383,6 @@ module.exports = {
322
383
};
323
384
```
324
385
325
- ** Note:** source with a ` tag ` option takes precedence over source without.
326
-
327
386
Filter can be used to disable default sources.
328
387
329
388
For example:
You can’t perform that action at this time.
0 commit comments