代码拉取完成,页面将自动刷新
let glob = require('glob');
const path = require('path');
//配置pages多页面获取当前文件夹下的html和js
function getEntry(globPath) {
let entries = {}, tmp, htmls = {};
// 读取src/pages/**/底下所有的html文件
glob.sync(globPath + 'html').forEach(function (entry) {
tmp = entry.split('/').splice(-3);
htmls[tmp[1]] = entry
})
// 读取src/pages/**/底下所有的js文件
glob.sync(globPath + 'js').forEach(function (entry) {
if (!entry.includes('/router')) {
tmp = entry.split('/').splice(-3);
entries[tmp[1]] = {
entry,
template: htmls[tmp[1]] ? htmls[tmp[1]] : 'index.html', // 当前目录没有有html则以共用的public/index.html作为模板
filename: './html/' + tmp[1] + '.html' // 以文件夹名称.html作为访问地址
};
}
});
return entries;
}
let htmls = getEntry('./src/pages/**/*.');
console.log(htmls);
module.exports = {
pages: htmls,
publicPath: process.env.NODE_ENV === 'production' ? '../' : '/',
outputDir: 'output', // 打包后的文件夹名称,默认dist
productionSourceMap: false,
css: {
loaderOptions: {
scss: {
prependData: `@import "./src/assets/style/common.scss";`
}
}
},
devServer: {
index: 'dispatch.html' // 默认启动页面
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。