加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
肖彦 提交于 2022-05-11 14:29 . 地图与遮罩层优化
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' // 默认启动页面
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化