Object.keys(entryMap).forEach((pageName) => {
// ensure entryMap from pages has been add to webpack entry
// webpack-dev-server may modify compilerOptions.entry, e.g add webpack-dev-server/client to every entry
compilerOptions.entry = Object.assign(
this.webpackEntry,
compilerOptions.entry,
);
// add an WebPlugin for every page to output an html
const {
templatePath,
templateCompiler,
htmlOutputFilename,
entryPath,
} = entryMap[pageName];
new WebPlugin({
...otherOptions,
template: templatePath,
templateCompiler,
pageName,
entryPath,
filename: `${htmlOutputFilename}.html`,
requires: requires.concat(pageName),
}).apply(compiler);
});
// call by webpack
apply(compiler) {
global._isProduction = util.isProduction(compiler);
global._isExtractStyle = util.isExtractStyle(compiler);
const { options: compilerOptions } = compiler;
const { entryMap } = this;
const { outputPagemap, outputPagemapFilename, requires = [], ...otherOptions } = this.options;