xiongzhu 3 سال پیش
والد
کامیت
4b87c384aa
2فایلهای تغییر یافته به همراه14 افزوده شده و 6 حذف شده
  1. 1 0
      .gitignore
  2. 13 6
      scripts/build.mjs

+ 1 - 0
.gitignore

@@ -8,3 +8,4 @@ dist-ssr
 tmp
 **/.tmp
 release
+.mode

+ 13 - 6
scripts/build.mjs

@@ -1,11 +1,18 @@
 import { build } from 'vite'
-console.log(process.argv)
+import { fileURLToPath } from 'url'
+import fs from 'fs'
+
 let mode = 'production'
-if (process.argv[2] === 'dev') {
-    mode = 'development'
-}
-if (process.argv[2] === 'test') {
-    mode = 'test'
+const modeFile = fileURLToPath(new URL('../.mode', import.meta.url))
+if (fs.existsSync(modeFile)) {
+    switch (fs.readFileSync(modeFile).toString()) {
+        case 'development':
+            mode = 'development'
+            break
+        case 'test':
+            mode = 'test'
+            break
+    }
 }
 await build({ configFile: 'packages/main/vite.config.js' })
 await build({ configFile: 'packages/preload/vite.config.js' })