增加轻量启动模式,只加载相关项目的代码,来减少构建,启动,刷新,调试所需要的时间
This commit is contained in:
		| @@ -44,7 +44,7 @@ export default { | ||||
|       let reg = new RegExp(`.*${this.searchApp?.replace(/-/g,'')||''}.*`, 'gi') | ||||
|       return (this.apps || []).filter(e => !this.searchApp || reg?.test(e.name) || reg?.test(e.label)).map(e => { | ||||
|         if (/\/project\//.test(e.path)) { | ||||
|           e.project = e.path.replace(/.*project\/([^\/]+)\/.+/, '$1') | ||||
|           e.project = process.env.VUE_APP_SCOPE || e.path.replace(/.*project\/([^\/]+)\/.+/, '$1') | ||||
|         } else if (/\/core\//.test(e.path)) { | ||||
|           e.project = "core" | ||||
|         } | ||||
| @@ -200,7 +200,7 @@ export default { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   :deep( .ai-menu ){ | ||||
|   :deep( .ai-menu ) { | ||||
|     padding-left: 0; | ||||
|     flex: 1; | ||||
|     min-height: 0; | ||||
| @@ -214,7 +214,7 @@ export default { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   :deep( .searchApp ){ | ||||
|   :deep( .searchApp ) { | ||||
|     display: flex; | ||||
|     align-items: center; | ||||
|     height: 44px; | ||||
|   | ||||
| @@ -2,7 +2,6 @@ import store from "../store"; | ||||
| import {waiting} from "../utils"; | ||||
| import appEntry from "../views/appEntry"; | ||||
| import router from "./router"; | ||||
| // import mods from "../modules" | ||||
|  | ||||
| export default { | ||||
|   routes: () => store.state.apps, | ||||
| @@ -11,16 +10,26 @@ export default { | ||||
|     store.commit("cleanApps") | ||||
|     // 自动化本工程应用 | ||||
|     waiting.init({innerHTML: '应用加载中..'}) | ||||
|     this.esm = { | ||||
|       all: { | ||||
|         packages: require.context('../../packages/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy'), | ||||
|         project: require.context('../../project/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy') | ||||
|       }, | ||||
|       dv: { | ||||
|         packages: require.context('../../packages/bigscreen', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy') | ||||
|       } | ||||
|     }[process.env.VUE_APP_SCOPE || "all"] | ||||
|     const startTime = new Date().getTime() | ||||
|     let startTime = new Date().getTime() | ||||
|     switch (process.env.VUE_APP_SCOPE) { | ||||
|       case 'dv': | ||||
|         this.esm = { | ||||
|           packages: require.context('../../packages/bigscreen', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy') | ||||
|         } | ||||
|         break | ||||
|       case 'fengdu': | ||||
|         this.esm = { | ||||
|           project: require.context('../../project/fengdu', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy') | ||||
|         } | ||||
|         break | ||||
|       default: | ||||
|         this.esm = { | ||||
|           packages: require.context('../../packages/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy'), | ||||
|           project: require.context('../../project/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy') | ||||
|         } | ||||
|     } | ||||
|     console.log('模块引用用了%s秒', (new Date().getTime() - startTime) / 1000) | ||||
|     startTime = new Date().getTime() | ||||
|     this.loadApps().finally(() => { | ||||
|       console.log('模块加载用了%s秒', (new Date().getTime() - startTime) / 1000) | ||||
|       waiting.close() | ||||
| @@ -53,6 +62,6 @@ export default { | ||||
|         return store.commit("addApp", addApp) | ||||
|       } else return 0 | ||||
|     }).catch(err => console.log(err)))) | ||||
|     return Promise.all(Object.entries(this.esm).map(([root, mods]) => promise(mods, root))) | ||||
|     return Promise.all(Object.entries(this.esm).map(([root, mods]) => promise(mods, root))).catch(console.error) | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
|   "scripts": { | ||||
|     "dev": "vue-cli-service serve", | ||||
|     "dev:dv": "set VUE_APP_SCOPE=dv&&vue-cli-service serve", | ||||
|     "dev:fengdu": "set VUE_APP_SCOPE=fengdu&&vue-cli-service serve", | ||||
|     "lib": "npm unpublish --force&&npm publish", | ||||
|     "ui": "npm run lib -w ui&&npm i dui@latest", | ||||
|     "sync": "node bin/appsSync.js" | ||||
|   | ||||
| @@ -1,4 +1,8 @@ | ||||
| const path = require('path'); | ||||
| const proxy = { | ||||
|   dv: "https://pingchangdjweb.icunwei.com/", | ||||
|   fengdu: "https://web.fdfengshou.cn/" | ||||
| }[process.env.VUE_APP_SCOPE] || "http://192.168.1.87:9000" | ||||
| module.exports = { | ||||
|   lintOnSave: false, | ||||
|   productionSourceMap: false, | ||||
| @@ -17,90 +21,33 @@ module.exports = { | ||||
|       filename: 'index.html' | ||||
|     } | ||||
|   }, | ||||
|   transpileDependencies: [/dui[\\\/]lib[\\\/]js/], | ||||
|   transpileDependencies: [/dui[\\\/]lib[\\\/]js/, /manifest.js/], | ||||
|   chainWebpack: (config) => { | ||||
|     config.module | ||||
|     .rule('js') | ||||
|     .include | ||||
|     .add(path.resolve(__dirname, 'packages')) | ||||
|     .add(path.resolve(__dirname, 'components')) | ||||
|     .add(path.resolve(__dirname, 'project')) | ||||
|     .add(path.resolve(__dirname, 'examples')) | ||||
|     .add(path.resolve(__dirname, 'ui')) | ||||
|     .end().use('babel').loader('babel-loader').tap(options => options); | ||||
|       .rule('js') | ||||
|       .include | ||||
|       .add(path.resolve(__dirname, 'packages')) | ||||
|       .add(path.resolve(__dirname, 'components')) | ||||
|       .add(path.resolve(__dirname, 'project')) | ||||
|       .add(path.resolve(__dirname, 'examples')) | ||||
|       .add(path.resolve(__dirname, 'ui')) | ||||
|       .end().use('babel').loader('babel-loader').tap(options => options); | ||||
|     config.plugin("limit").use(require("webpack/lib/optimize/LimitChunkCountPlugin"), [{maxChunks: 10}]).tap(options => options) | ||||
|   }, | ||||
|   devServer: { | ||||
|     host: '0.0.0.0', //主机地址 | ||||
|     port: 80, //端口号 | ||||
|     open: true, | ||||
|     // devtool: 'cheap-module-eval-source-map', | ||||
|     proxy: { | ||||
|       //设置代理,可解决跨5 | ||||
|       //设置代理,可解决跨 | ||||
|       '/lan': { | ||||
|         target: 'http://192.168.1.87:9000', | ||||
|         target: proxy, | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/lan': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/analysis': { | ||||
|         target: 'http://192.168.1.87:22001', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/analysis': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/saas': { | ||||
|         target: 'http://192.168.1.34:19898', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/saas': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/omsapi': { | ||||
|         target: 'http://192.168.1.87:19897', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/omsapi': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/ns': { | ||||
|         target: 'http://192.168.1.87:12525', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/ns': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/lns': { | ||||
|         target: 'http://localhost:12525', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/lns': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/tfx': { | ||||
|         target: 'http://192.168.1.87:59998', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/tfx': '/' | ||||
|         } | ||||
|       }, | ||||
|       '/map': { | ||||
|         target: 'https://geo.datav.aliyun.com', | ||||
|         changeOrigin: true, | ||||
|         pathRewrite: { | ||||
|           //地址重写 | ||||
|           '^/map': '/' | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     disableHostCheck: true, | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user