-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello @hqw567, thanks for the question. I can't think of a use case with empty If you need to disable the Disable the processing of an attributeconst HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
module.exports = {
plugins: [
new HtmlBundlerPlugin({
entry: {
index: 'src/views/index.html',
},
loaderOptions: {
sources: [
// disable the processing of attribute srcset of the img tag
{
tag: 'img',
filter: ({ attribute }) => attribute !== 'srcset',
}
],
},
}),
],
}; Ignore the processing of an empty attributeconst HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
module.exports = {
plugins: [
new HtmlBundlerPlugin({
entry: {
index: 'src/views/index.html',
},
loaderOptions: {
sources: [
// ignore the processing of an empty srcset attribute of the img tag
{
tag: 'img',
filter: ({ attribute, value }) => attribute === 'srcset' && value !== '',
}
],
},
}),
],
}; For debugging, you can disable an attribute adding any prefix to attribute name, e.g.: Defaults, the standard attributes will be parsed: <img src="./image.png" srcset=""> Ignore non standard attributes: <img x-src="./image.png" x-srcset=""> |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your help! |
Beta Was this translation helpful? Give feedback.
Hello @hqw567,
thanks for the question.
I can't think of a use case with empty
srcset
attribute.Yes, defaults behaviour throws an exception, this is right. An empty srcset attribute means you forgot to define the source file, otherwise what's the reason of having an empty attribute?
If you need to disable the
srcset
attribute or ignore an empty value, use the loader optionsources
:Disable the processing of an attribute