About resolvePublicPath
hi ,
is there some problem when call function util.resolvePublicPath with publicPath is undefined,
it doesn't return the relative path from the html template;
`function resolvePublicPath(compilation, filename) { /* istanbul ignore else */ const publicPath = typeof compilation.options.output.publicPath !== 'undefined' ? compilation.options.output.publicPath : _path().default.relative(_path().default.dirname(filename), '.'); // TODO: How to test this? I haven't written this logic, unsure what it does
return ensureTrailingSlash(publicPath); }`
change to
`function resolvePublicPath(compilation, filename, childCompilationOutputName) {
//Copied from html-webpack-plugin var publicPath = typeof compilation.options.output.publicPath !== 'undefined' ? compilation.options.output.publicPath : _path().default.relative(_path().default.resolve(compilation.options.output.path, _path().default.dirname(childCompilationOutputName)), compilation.options.output.path) .split(_path().default.sep).join('/');
return ensureTrailingSlash(publicPath); } `
will compile the correct relative path
childCompilationOutputName = htmlPluginData.outputName
Would you mind sending a PR to fix that? 🙂
Code: https://github.com/SimenB/add-asset-html-webpack-plugin/blob/6f74d9c39108ca6178fa8638acf9721a42d820ba/src/utils.js#L12-L21