1. Introduce the generated vendor_library into plugins
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require("./dll/vendor-manifest.json"),
name: "vendor_library",
sourceType : "vendor_library"
})
2, webpack needs to generate multiple pages
//dll
["Admin","Class"].forEach(function(name) {
webpackConfig.entry[name] = "./src/"+name+"/index";
const plugin = new HtmlWebpackPlugin({
filename: name + ".html",
template: "./public/index.html",
inject: true,
chunks: [name],
});
webpackConfig.plugins.push(plugin);
})
//dll
webpackConfig.entry["classroom"] = "./src/Classroom/index";
webpackConfig.plugins.push(
new HtmlWebpackPlugin({
filename: "classroom.html",
template: "ejs-render-loader!./src/Classroom/tpl/index.ejs",
inject: true,
chunks: ["classroom"]
})
);
3, related templates
Admin.htmlClass.html
scriptdll: <script src="/js/vendor.dll.js"></script>
./src/Classroom/tpl/index.ejs
dll
vendor_library is not definded
4, expected results
classroom dll
DllReferencePlugin chunks ["Admin","Class"],