Closed andreivictor closed 8 months ago
Hello @andreivictor,
to disable the resolving of URLs in all attributes, set the sources option as false
.
Or use the filter of sources option to disable resolving an attribute by tag/attribute/value.
For example, the source script and style files in HTML should be resolved and processed, but all images are already coped via copy-plugin
into dist/
directory, then disable resolving only src
attribute of image tag:
new HtmlBundlerPlugin({
entry: {
index: 'src/views/index.html',
},
loaderOptions: {
sources: [
{
tag: 'img',
filter: ({ attribute }) => attribute !== 'src',
}
],
},
}),
If you will disable resolving both the src
and srcset
attributes, then use the filter:
filter: ({ attribute }) => !['src', 'srcset'].includes(attribute),
The details see please in the documentation.
I don't use the comment like <!-- webpackIgnore: true -->
to disable sources handling, because it's a bad idea.
Excellent! The sources.filter
option is exactly what I needed.
Thank you for your response.
Let's consider that in the
html
entry file there are some resources that should not be resolved by webpack - these resources will be placed in thepublic
folder and copied in the dist folder withwebpack-copy-plugin.
To be more clear, the behaviour is similar with the
html-loader
feature - https://github.com/webpack-contrib/html-loader#examples.Is there any built-in option in this plugin?
Thank you!