提交一下
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"name": "dvcp-vite-webapps",
|
"name": "dvcp-vite-webapps",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"main": "lib/dvcp-vite-webapps.umd.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
|||||||
@@ -10,27 +10,22 @@ const install = function (Vue, params) {
|
|||||||
if (install.installed) return
|
if (install.installed) return
|
||||||
// 遍历注册全局组件
|
// 遍历注册全局组件
|
||||||
let apps = []
|
let apps = []
|
||||||
let contexts = require.context('.', true, /\.(\/.+)\/App[^\/]+\.vue$/)
|
let contexts = import.meta.glob('./**/App*.vue')
|
||||||
if (contexts) {
|
if (contexts) {
|
||||||
contexts.keys().map(e => {
|
Object.keys(contexts).map(path => {
|
||||||
if (contexts(e).default) {
|
if (/App[A-Z]\w+\.vue/.test(path)) {
|
||||||
if (params?.apps) {
|
return contexts?.[path]()?.then(file => {
|
||||||
if (params?.apps.includes(contexts(e).default.name)) {
|
apps.push(file.default)
|
||||||
apps.push(contexts(e).default)
|
return Vue.component(file.default.name, file.default)
|
||||||
Vue.component(contexts(e).default.name, contexts(e).default)
|
})
|
||||||
}
|
|
||||||
} else {
|
|
||||||
apps.push(contexts(e).default)
|
|
||||||
Vue.component(contexts(e).default.name, contexts(e).default)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
!!params?.showList && console.log(apps.map(e => e.name))
|
|
||||||
}
|
}
|
||||||
core?.map(app => {
|
core?.map(app => {
|
||||||
apps.push(app.component)
|
apps.push(app.component)
|
||||||
Vue.component(app.name, app.component)
|
Vue.component(app.name, app.component)
|
||||||
})
|
})
|
||||||
|
!!params?.showList && console.log(apps.map(e => e.name))
|
||||||
return Promise.resolve(apps)
|
return Promise.resolve(apps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
lib: {
|
lib: {
|
||||||
entry: path.resolve(__dirname, 'packages/index.js'),
|
entry: path.resolve(__dirname, 'packages/index.js'),
|
||||||
name:"dvcp-vite-webapps"
|
name: "dvcp-vite-webapps",
|
||||||
}
|
},
|
||||||
|
chunkSizeWarningLimit: 2048
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user