staven630 / vue-cli4-config

vue-cli4配置vue.config.js持续更新

Home Page:https://staven630.github.io/vue-cli4-config/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

htmlWebpackPlugin多页面配置 templateParameters报错Cannot read property 'title' of undefined

xcgs123 opened this issue · comments

commented

// 多页面配置
配置了templateParameters,报错Cannot read property 'title' of undefined,有遇到过同样问题的吗

let publicPath = process.env.PUBLIC_PATH;

glob.sync('./src/**/main.js').forEach(entry => {
   
let publicPath = process.env.PUBLIC_PATH;
     let chunk = entry.match(/\.\/src\/(.*)\/main\.js/)[1];
    const curr = pagesInfo[chunk];
    if (curr) {
        pages[chunk] = {
            entry,
            ...curr,
            templateParameters: (compilation, assets, assetTags, options) => {// 配置了对象,报错html-webpack-plugin is not defined
                return {
                    compilation,
                    webpackConfig: compilation.options,
                    htmlWebpackPlugin: {
                        tags: assetTags,
                        files: assets,
                        options
                    },
                    publicPath
                };
            }
        };
    }
});

    home: {
        entry: 'src/home/main.js',
        template: 'entry/index.html',
        filename: 'home/index.html',
        title: '平台'
    },