I just had an issue with pathnames with multiple slashes(/.../).
With default behavior, it generates following scripts:
<script type="text/javascript" src="bundle.js"></script>
In SPA, If we navigate to URL like http://somehost/path1/path2, it try to load assets from http://somehost/path1/bundle.js, not http://somehost/bundle.js so it failed to initialize the application.
I found that we can override the path via setting publicPath to '/' so that every assets can be loaded from root path, but the default publicPath value was ''.
Is there any reason that default behavior is not generated with '/'?
Default publicPath goes from your webpack config output.publicPath, which maybe set or maybe not. If you ask why webpack doesn't have output.publicPath set to / by default then it would be better to ask that question in webpack's repo.
If you ask why html-webpack-plugin doesn't have it set to / by default when publicPath is missing, then it's simple (I assume why it's so here): because having it as output.publicPath is a good default. After all, you don't want to have troubles with someone intentionally net setting output.publicPath but suddenly having publicPath as / in html-webpack-plugin.
Correct :)
It would not allow to have relative paths
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Default
publicPathgoes from your webpack configoutput.publicPath, which maybe set or maybe not. If you ask why webpack doesn't haveoutput.publicPathset to/by default then it would be better to ask that question in webpack's repo.If you ask why
html-webpack-plugindoesn't have it set to/by default whenpublicPathis missing, then it's simple (I assume why it's so here): because having it asoutput.publicPathis a good default. After all, you don't want to have troubles with someone intentionally net settingoutput.publicPathbut suddenly havingpublicPathas/inhtml-webpack-plugin.