首页 > 其他 > 详细

vue cli3配置多页面入口

时间:2020-07-08 00:52:01      阅读:119      评论:0      收藏:0      [点我收藏+]
使用vue 配置多入口

因为懒,所以要提高开发效率,因为懒,所以要安装第三方依赖

  • 使用glob自动加载
yarn add glob -D  //安装依赖
  • 配置vue.config.js
const getEntries =(pathUrl)=>{
    let pages={}
    glob.sync(pathUrl).map(filePath=>{
        const fileName=filePath.substring(filePath.lastIndexOf("/")+1,filePath.lastIndexOf("."))
        pages[fileName]={
                /* 返回对应的入口页面配置,详情见vue-cli官网 */
            template: `${filePath.substring(0, filePath.lastIndexOf("."))}.html`, 
            entry:filePath, 
            filename: fileName+".html",
            chunks: [‘manifest‘, ‘chunk-vendors‘,‘chunk-common‘,fileName],
            title:fileName
        }
    })
    console.log(pages)
    return pages
}
const entries = getEntries("src/entries/**/*.js")  //入口文件夹位置
module.exports={
pages:entries,//配置多入口
}

vue cli3配置多页面入口

原文:https://blog.51cto.com/5353088/2509336

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!