yanghao 3 hete
szülő
commit
f9c19ec870
7 módosított fájl, 92 hozzáadás és 37 törlés
  1. 0 2
      .env
  2. 2 1
      .env.dev
  3. 2 0
      .env.prod
  4. 0 0
      .env.stage
  5. 0 0
      .env.test
  6. 5 1
      package.json
  7. 83 33
      vite.config.ts

+ 0 - 2
.env

@@ -2,5 +2,3 @@ VITE_APP_TITLE='科瑞石油技术门户网站'
 
 VITE_DINGTALK_APP_ID='dingmr9ez0ecgbmscfeb'
 VITE_DINGTALK_REDIRECT_URI='http://iot.deepoil.cc:5172/login?loginType=dingding&type=20'
-
-VITE_BASE_URL='http://iot.deepoil.cc:5172'

+ 2 - 1
.env.dev

@@ -1 +1,2 @@
-VITE_BASE_URL='https://iot.deepoil.cc/admin-api'
+VITE_BASE_URL='https://iot.deepoil.cc'
+VITE_PMS_URL='https://iot.deepoil.cc'

+ 2 - 0
.env.prod

@@ -0,0 +1,2 @@
+VITE_BASE_URL='https://portal.deepoil.cc'
+VITE_PMS_URL='https://aims.deepoil.cc'

+ 0 - 0
.env.stage


+ 0 - 0
.env.test


+ 5 - 1
package.json

@@ -8,7 +8,11 @@
   },
   "scripts": {
     "dev": "vite",
-    "build": "run-p type-check \"build-only {@}\" --",
+    "build:local": "node --max_old_space_size=4096 ./node_modules/vite/bin/vite.js build",
+    "build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode dev",
+    "build:test": "node --max_old_space_size=4096 ./node_modules/vite/bin/vite.js build --mode test",
+    "build:stage": "node --max_old_space_size=4096 ./node_modules/vite/bin/vite.js build --mode stage",
+    "build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod",
     "preview": "vite preview",
     "build-only": "vite build",
     "type-check": "vue-tsc --build"

+ 83 - 33
vite.config.ts

@@ -1,45 +1,95 @@
 import { fileURLToPath, URL } from "node:url";
 
-import { defineConfig } from "vite";
 import vue from "@vitejs/plugin-vue";
 import vueDevTools from "vite-plugin-vue-devtools";
 import tailwindcss from "@tailwindcss/vite";
+import type { ConfigEnv, UserConfig } from "vite";
+import { loadEnv } from "vite";
 
 import AutoImport from "unplugin-auto-import/vite";
 import Components from "unplugin-vue-components/vite";
 import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
 import MotionResolver from "motion-v/resolver";
 
-export default defineConfig({
-  server: {
-    host: "0.0.0.0", // 监听所有网络接口
-    port: 5173, // 可选:指定端口
-  },
-  base: "./",
-  plugins: [
-    vue(),
-    vueDevTools(),
-    tailwindcss(),
-    AutoImport({
-      resolvers: [ElementPlusResolver()],
-    }),
-    Components({
-      dts: true,
-      resolvers: [ElementPlusResolver(), MotionResolver()],
-    }),
-  ],
-  resolve: {
-    alias: {
-      "@": fileURLToPath(new URL("./src", import.meta.url)),
-      "@components": fileURLToPath(
-        new URL("./src/components", import.meta.url)
-      ),
-      "@assets": fileURLToPath(new URL("./src/assets", import.meta.url)),
-      "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
-      "@utils": fileURLToPath(new URL("./src/utils", import.meta.url)),
-      "@types": fileURLToPath(new URL("./src/types", import.meta.url)),
-      "@stores": fileURLToPath(new URL("./src/stores", import.meta.url)),
-      "@hooks": fileURLToPath(new URL("./src/hooks", import.meta.url)),
+const root = process.cwd();
+
+// export default defineConfig({
+//   server: {
+//     host: "0.0.0.0", // 监听所有网络接口
+//     port: 5173, // 可选:指定端口
+//   },
+//   base: "./",
+//   plugins: [
+//     vue(),
+//     vueDevTools(),
+//     tailwindcss(),
+//     AutoImport({
+//       resolvers: [ElementPlusResolver()],
+//     }),
+//     Components({
+//       dts: true,
+//       resolvers: [ElementPlusResolver(), MotionResolver()],
+//     }),
+//   ],
+//   resolve: {
+//     alias: {
+//       "@": fileURLToPath(new URL("./src", import.meta.url)),
+//       "@components": fileURLToPath(
+//         new URL("./src/components", import.meta.url)
+//       ),
+//       "@assets": fileURLToPath(new URL("./src/assets", import.meta.url)),
+//       "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
+//       "@utils": fileURLToPath(new URL("./src/utils", import.meta.url)),
+//       "@types": fileURLToPath(new URL("./src/types", import.meta.url)),
+//       "@stores": fileURLToPath(new URL("./src/stores", import.meta.url)),
+//       "@hooks": fileURLToPath(new URL("./src/hooks", import.meta.url)),
+//     },
+//   },
+// });
+
+export default ({ command, mode }: ConfigEnv): UserConfig => {
+  let env = {} as any;
+  const isBuild = command === "build";
+  if (!isBuild) {
+    env = loadEnv(
+      process.argv[3] === "--mode" ? process.argv[4] : process.argv[3],
+      root,
+    );
+  } else {
+    env = loadEnv(mode, root);
+  }
+
+  return {
+    server: {
+      host: "0.0.0.0", // 监听所有网络接口
+      port: 5173, // 可选:指定端口
+    },
+    base: "./",
+    plugins: [
+      vue(),
+      vueDevTools(),
+      tailwindcss(),
+      AutoImport({
+        resolvers: [ElementPlusResolver()],
+      }),
+      Components({
+        dts: true,
+        resolvers: [ElementPlusResolver(), MotionResolver()],
+      }),
+    ],
+    resolve: {
+      alias: {
+        "@": fileURLToPath(new URL("./src", import.meta.url)),
+        "@components": fileURLToPath(
+          new URL("./src/components", import.meta.url),
+        ),
+        "@assets": fileURLToPath(new URL("./src/assets", import.meta.url)),
+        "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
+        "@utils": fileURLToPath(new URL("./src/utils", import.meta.url)),
+        "@types": fileURLToPath(new URL("./src/types", import.meta.url)),
+        "@stores": fileURLToPath(new URL("./src/stores", import.meta.url)),
+        "@hooks": fileURLToPath(new URL("./src/hooks", import.meta.url)),
+      },
     },
-  },
-});
+  };
+};