javascript - webpack 多入口文件生成HTML文件;
问题描述
多入口文件生成HTML文件;根据入口文件的数量,来生成html;例如:
这里有两个入口文件,home和about;
使用html-webpack-plugin插件来new ;如下:

根据入口文件的数量来生成HTMl;例如:上面有两个入口文件;在下面的的时候就new 两次;有没有可能把这个封装一下;来动态生存;不需要手动去配置;我写了一半,写不下去了;
求各位大谁给个DOME;有思路但是具体的方法不知道怎么去实现;node小白;;
xydArray.forEach(function(item){
var xydConf = { filename: ’./’+item+’.html’, template: ’./’+item+’.html’, chunks:[item], inject:true, hash:true}config.plugins.push(new htmlWebpackPlugin(xydConf));
});
module.exports = config;
xydArray就是入口文件的key值
问题解答
回答1:const pages = [ { name: ’page0’, title: ’page0’, }, { name: ’page1’, title: ’page1’, }, { name: ’page2’, title: ’page2’, },];const plugins = pages.map(({ name, title }) => new HtmlWebpackPlugin({ title, chunks: [name], filename: path.resolve(__dirname, `build/${name}.html`), template: path.resolve(__dirname, ’app/template.html’),}));
相关文章:
1. angular.js - angular内容过长展开收起效果2. docker start -a dockername 老是卡住,什么情况?3. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””4. dockerfile - [docker build image失败- npm install]5. boot2docker无法启动6. docker容器呢SSH为什么连不通呢?7. html5 - 响应式WEB,媒体查询的问题。8. javascript - ueditor引入报错问题9. nignx - docker内nginx 80端口被占用10. dockerfile - 为什么docker容器启动不了?

网公网安备