用VUE/cli 4.1 搭建的项目,需要配制vue.config.js以实现多页面开发
1、开发PC端多页面(约几十个)网页
2、有最基本的SEO要求
希望提供代码,网上查了很多,对于现在的前端而言,半年前已经算上年代久远了,也不知道是不是最好的方案
用VUE/cli 4.1 搭建的项目,需要配制vue.config.js以实现多页面开发
1、开发PC端多页面(约几十个)网页
2、有最基本的SEO要求
希望提供代码,网上查了很多,对于现在的前端而言,半年前已经算上年代久远了,也不知道是不是最好的方案
自己动手丰衣足食,有需要的找我,问一次5元,哈哈
const glob = require("glob"); , const PAGE_PATH = './src/pages'; exports.setPages = configs => { let entryFiles = glob.sync(PAGE_PATH + '/*/*.js'); let map = {}; entryFiles.forEach(filePath => { let filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.lastIndexOf('.')); let tmp = filePath.substring(0, filePath.lastIndexOf('.')); let conf = { // page 的入口 entry: filePath, // 模板来源 template: tmp + '.html', // 在 dist/index.html 的输出 filename: filename + '.html', inject: true, //生成的JS位于页面的什么位置,true是默认值是可以不写的 }; if (configs) { conf = merge(conf, configs) } if (process.env.NODE_ENV === 'production') { conf = merge(conf, { minify: { removeComments: true, // 删除 html 中的注释代码 collapseWhitespace: true, // 删除 html 中的空白符 // removeAttributeQuotes: true // 删除 html 元素中属性的引号 }, chunksSortMode: 'manual'// 按 manual 的顺序引入 }) } map[filename] = conf }); return map };