Skip to content

Commit f0bfe2a

Browse files
docs: add example with custom attribute (#326)
1 parent 32e7ba6 commit f0bfe2a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,41 @@ module.exports = {
280280
};
281281
```
282282

283+
Filter can also be used to extend the supported elements and attributes. For example, filter can help process meta tags that reference assets:
284+
285+
```js
286+
module.exports = {
287+
module: {
288+
rules: [
289+
{
290+
test: /\.html$/i,
291+
loader: 'html-loader',
292+
options: {
293+
attributes: {
294+
list: [
295+
{
296+
tag: 'meta',
297+
attribute: 'content',
298+
type: 'src',
299+
filter: (tag, attribute, attributes, resourcePath) => {
300+
if (
301+
attributes.property === 'og:image' ||
302+
attributes.name === 'twitter:image'
303+
) {
304+
return true;
305+
}
306+
return false;
307+
},
308+
},
309+
],
310+
},
311+
},
312+
},
313+
],
314+
},
315+
};
316+
```
317+
283318
#### `urlFilter`
284319

285320
Type: `Function`

0 commit comments

Comments
 (0)