From d954f779d250b9a8ba3226e27ce42ec362ae3199 Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周二, 06 5月 2025 13:43:30 +0800
Subject: [PATCH] 添加生成器数据库配置
---
HIAWms/web/vite.lib.config.ts | 48 +++++++++++-------------------------------------
1 files changed, 11 insertions(+), 37 deletions(-)
diff --git a/HIAWms/web/vite.lib.config.ts b/HIAWms/web/vite.lib.config.ts
index 00b95dd..a76ad4e 100644
--- a/HIAWms/web/vite.lib.config.ts
+++ b/HIAWms/web/vite.lib.config.ts
@@ -14,38 +14,26 @@
import VueTypeImports from 'vite-plugin-vue-type-imports'
const execa = require('execa')
const isWin = process.platform === 'win32'
-let getWidgetNames: Array<string> = []
const argvPath: string = './script/.argv'
-const isAllBuild = existsSync(argvPath)
+const isSingleBuild = existsSync(argvPath)
+const nodeIndex = process.env.NODE_INDEX
+const baseBuildFile = './node_modules/.cache/widgets.json'
+let getWidgetNames: Array<string> = []
-function getGitHash() {
- return execa('git', ['rev-parse', '--short', 'HEAD'])
-}
-
-function getGitBranch() {
- return execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'])
-}
-
-function getGitUserName() {
- return execa('git', ['config', 'user.name'])
-}
-
-if (isAllBuild) {
+if (isSingleBuild) {
const widgetName = readFileSync(argvPath, { encoding: 'utf8' })
getWidgetNames.push(widgetName)
} else {
- const widgetsPath = globSync(`./src/widgets/*/index.ts`)
- getWidgetNames = widgetsPath.map((file) => {
- const parts = isWin
- ? path.resolve(file).split('\\')
- : path.resolve(file).split('/')
- return parts[parts.length - 2]
- })
+ // 鎵ц澶氭牳鍛戒护鎵撳寘
+ if (nodeIndex) {
+ const widgetNameMap = require(path.resolve(process.cwd(), baseBuildFile))
+ getWidgetNames = widgetNameMap[nodeIndex]
+ }
}
const library: any = getWidgetNames.map((name) => {
return {
- outDir: isWin ? 'C:/Program Files/CMS Editor/host/wwwroot/widgets' : 'dist',
+ outDir: isWin ? 'D:/syc/CMS Editor/host/wwwroot/widgets' : 'dist',
target: 'ES2022',
rollupOptions: {
external: ['vue', 'sdk'],
@@ -69,24 +57,10 @@
//@ts-ignore
export default defineConfig(async ({ mode }) => {
- let commit
- let branch
- let userName
- try {
- commit = await getGitHash()
- branch = await getGitBranch()
- userName = await getGitUserName()
- } catch (e) {
- console.log(e)
- }
-
return {
define: {
'process.env': process.env,
'window.__BUILD_TIME__': `"${dayjs().format('YYYY-MM-DD HH:mm:ss')}"`,
- 'window.__COMMIT__': `"${commit?.stdout}"`,
- 'window.__BRANCH__': `"${branch?.stdout}"`,
- 'window.__USER_NAME__': `"${userName?.stdout}"`,
},
resolve: {
alias: {
--
Gitblit v1.9.3