Support opt-out the automatically added trailing slash for publicPath
Author: weareoutmanCreated Nov 10, 2021Updated Jan 2, 2026
Labelswontfix
Is your feature request related to a problem? Please describe.
I want to set my publicPath to something like <!--# echo var='public_path' default='' -->, which is a nginx ssi expression.
I have a config like:
new HtmlWebpackPlugin({
filename: "index.html",
publicPath: "<!--# echo var='public_path' default='' -->",
}),I want the output html to be like:
<script src="<!--# echo var='core_root' default='' -->main.js"></script>But it automatically added a trailing slash for the publicPath, it output:
<script src="<!--# echo var='core_root' default='' -->/main.js"></script>
^Describe the solution you'd like
It would be nice to have an option to opt-out the automatically added trailing slash for publicPath.
Something like:
new HtmlWebpackPlugin({
filename: "index.html",
publicPath: "<!--# echo var='public_path' default='' -->",
publicPathTrailingSlash: false,
}),P.S. I am using webpack v4 along with html-webpack-plugin v4, so supports it in v4 would be nice, thank you.
Source: jantimon/html-webpack-plugin