-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiPage.config
34 lines (33 loc) · 1.39 KB
/
MultiPage.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 多页面配置
const fs = require('fs');
const path = require('path');
const fileNames = fs.readdirSync(path.resolve(__dirname, './src/views'));
const MutiPageConfig = {
'main': {
// page 的入口
entry: `src/main.js`,
// 模板来源
template: `./public/index.html`,
// 在 dist 的输出
filename: `index.html`,
// 当使用 title 选项时,template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: 'Main',
// 在这个页面中包含的块,默认情况下会包含提取出来的通用 chunk 和 vendor chunk,如果自己有 splitChunks 选项,可以在此添加
chunks: ['vendor', 'manifest', 'main']
}
};
fileNames.forEach((pageName) => {
MutiPageConfig[pageName] = {
// page 的入口
entry: `src/views/${pageName}/index.js`,
// 模板来源
template: `./public/index.html`,
// 在 dist 的输出
filename: `views/${pageName}/index.html`,
// 当使用 title 选项时,template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: pageName,
// 在这个页面中包含的块,默认情况下会包含提取出来的通用 chunk 和 vendor chunk,如果自己有配置 splitChunks 选项,可以在此添加
chunks: ['vendor', 'manifest', pageName]
}
});
module.exports = {pageNum: fileNames.length, MutiPageConfig: MutiPageConfig};