after webpack4 multi-entry application uses splitChunks split code, HtmlWebpackPlugin cannot inject vendor.bundle and runtime.bundle
entry:
entry: {
app: path.join(__dirname, "../src/app.js"),
main: path.join(__dirname, "../src/main.js")
},
HtmlWebpackPlugin configuration
new HtmlWebpackPlugin({
chunks: ["main"],
filename: "main.html",
template: path.join(__dirname, "../index.html"),
inject: true,
minify: {
removeComments: true
}
}),
new HtmlWebpackPlugin({
title: "app",
chunks: ["app"],
filename: "app.html",
template: path.join(__dirname, "../app.html"),
inject: true,
minify: {
removeComments: true
}
})
optimization configuration
optimization: {
splitChunks: {
chunks: "all"
},
runtimeChunk: {}
}
after packing:
main.html main.bundlevendors~main.bundle.jsruntime~main.bundle.js
Why?