Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About resolvePublicPath #139

Open
pigchao opened this issue Oct 25, 2018 · 1 comment
Open

About resolvePublicPath #139

pigchao opened this issue Oct 25, 2018 · 1 comment
Labels

Comments

@pigchao
Copy link

pigchao commented Oct 25, 2018

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

@SimenB
Copy link
Owner

SimenB commented Oct 25, 2018

Would you mind sending a PR to fix that? 🙂

Code:

// Copied from html-webpack-plugin
export function resolvePublicPath(compilation, filename) {
/* istanbul ignore else */
const publicPath =
typeof compilation.options.output.publicPath !== 'undefined'
? compilation.options.output.publicPath
: path.relative(path.dirname(filename), '.'); // TODO: How to test this? I haven't written this logic, unsure what it does
return ensureTrailingSlash(publicPath);
}

@SimenB SimenB added the bug label Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants