Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xcgs123 opened this issue Apr 14, 2021 · 0 comments

Comments

@xcgs123
Copy link

xcgs123 commented Apr 14, 2021

// 多页面配置
配置了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: '平台'
    },
@xcgs123 xcgs123 changed the title 多页面配置 htmlWebpackPlugin htmlWebpackPlugin多页面配置 templateParameters报错Cannot read property 'title' of undefined Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant