const glob = require('glob') const pages = {}; module.exports.pages = function getPages() { glob.sync('./src/pages/*/*.js').forEach((filepath) => { const fileList = filepath.split('/') const fileName = fileList[fileList.length - 2] pages[fileName] = { // entry: `src/pages/${fileName}/${fileName}.js`, entry: `src/pages/${fileName}/index.js`, // 模板来源 // template: `src/pages/${fileName}/${fileName}.html`, template: 'public/index.html', // 在 dist/index.html 的输出 filename: process.env.NODE_ENV === 'development' ? `${fileName}/index.html` : `${fileName}/index.html`, // 提取出来的通用 chunk 和 vendor chunk。 chunks: ['chunk-vendors', 'chunk-common', fileName], // favicon: '../favicon.ico' } }) return pages; }; const configs = []; module.exports.configs = function getConfigs() { glob.sync('./src/pages/*/config.json').forEach((filepath) => { const fileList = filepath.split('/') const fileName = fileList[fileList.length - 2] configs.push({ from: `src/pages/${fileName}/config.json`, to: process.env.NODE_ENV === 'development' ? `${fileName}/config.json` : `${fileName}/config.json` }) }) return configs; };