read the Chinese and English documents and say that instead of output.publicPath, you need to set output.publicPath to"", and then set webpack_public_path =" http://a.com"; in the entry file.
the expected result is that the js import address in the html file packaged by htmlwebpackplugin is" http "/ / a.compool xx.js"
webpack.config.js is set as follows:
output: {
filename: "[name].[hash:8].js",
publicPath: ""
}
the htmlwebpackplugin plug-in is set as follows:
let entries = glob.sync("./src/entries/**/index.js").reduce((prev, curr) => {
prev["assets/" + curr.slice(14, -3)] = curr;
return prev;
}, {}); // entries webpack entry js
let htmls = Object.keys(entries).map((html) => {
return new HWP({
title: html.slice(-5, -1), // ,
filename: `${html.slice(7, -6)}.html`, // ,
template: "./src/tpl/index.html",
chunks: [html], // ,
inject: "body", // ,
minify: false,
data: {
build: true
}
});
});
the entry file is set as follows:
__webpack_public_path__ = "http://a.com";
import a from "./a.js";
import b from "./b.js";
blabla...