add-asset-html-webpack-plugin
add-asset-html-webpack-plugin copied to clipboard
the src of script is wrong with html-webpack-plugin v5.3.1
1.the config:
plugins:[ new HtmlWebpackPlugin({ template: './src/index.html' }), new webpack.DllReferencePlugin({ manifest: resolve(__dirname, 'dll/manifest.json') }), new AddAssetHtmlWebpackPlugin({ filepath: require.resolve("./dll/jquery.js") }) ]
2.run 'webpack'
success
3.but the inserted script label is wrong
inserted script
<script defer="defer" src="auto/jquery.js"></script>
the src should be 'jquery.js' rather than 'auto/jquery.js'
4.It's may a bug, would you mind give some advice?
@greenHandOnWeb I have this issue too. Did you find a workaround?
I found a solution. We need to use the publicPath
option with empty string. My config now is:
new AddAssetHtmlPlugin({
filepath: path.resolve(__dirname, '../public/properties.js'),
includeRelatedFiles: false,
publicPath: '',
})
I think it's because util.js use compilation.options.output.publicPath, if not set it, it will be 'auto', I not sure it's bug or not.
- https://github.com/SimenB/add-asset-html-webpack-plugin/blob/ca2fb7743ad5e3d4ab8092e19e28a40bad2fe3d4/src/utils.js#L16-L19
or webpack config =
{
mode: "development",
output: {
publicPath: "", //add this line
PR very much welcome that fixes this