Parcourir la source

reactor:错误修复

zhangchong il y a 1 an
Parent
commit
192caa477c
4 fichiers modifiés avec 15 ajouts et 28 suppressions
  1. 1 0
      .env.yibin
  2. 1 1
      package.json
  3. 0 1
      src/utils/signalR.ts
  4. 13 26
      vite.config.ts

+ 1 - 0
.env.yinbin → .env.yibin

@@ -1,4 +1,5 @@
 # 宜宾环境
+VITE_NODE_ENV=yibin
 VITE_MODE_NAME=yibin
 # #socket API
 VITE_API_SOCKET_URL=http://218.6.151.146:50100/hubs/hotline

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
   "scripts": {
     "dev": "vite",
     "build": "vite build",
-    "build:yibin": "vite --mode yibin",
+    "build:yibin": "vite build --mode yibin",
     "preview": "vite preview --port 4173"
   },
   "dependencies": {

+ 0 - 1
src/utils/signalR.ts

@@ -1,7 +1,6 @@
 // 官方文档:https://docs.microsoft.com/zh-cn/aspnet/core/signalr/javascript-client?view=aspnetcore-6.0&viewFallbackFrom=aspnetcore-2.2&tabs=visual-studio
 import * as signalR from '@microsoft/signalr';
 import mittBus from '@/utils/mitt';
-console.log(' process.env: ', import.meta.env);
 // console.log(import.meta.env.VITE_API_SOCKET_URL,'import.meta.env.VITE_API_SOCKET_URL');
 export default {
     // signalR对象

+ 13 - 26
vite.config.ts

@@ -1,37 +1,16 @@
-
-import type { UserConfig, ConfigEnv } from 'vite';
-import { defineConfig } from 'vite'
+import { defineConfig, ConfigEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import { resolve } from "path";
-import AutoImport from 'unplugin-auto-import/vite'
-import Components from 'unplugin-vue-components/vite'
-import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
 import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'; // setup语法糖设置name
 import viteCompression from "vite-plugin-compression"; //开启gzip打包压缩
-export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
-
-  // const env = loadEnv(mode, process.cwd(), '')
-  console.log(command, mode);
+// @ts-ignore
+export default defineConfig((mode: ConfigEnv) => {
   return {
     plugins: [vue(),
     vueSetupExtend(),
-    AutoImport({
-      resolvers: [ElementPlusResolver()],
-    }),
-    Components({
-      resolvers: [ElementPlusResolver()],
-    }),
       viteCompression()
     ],
-    publicDir: "public",
-    base: "./",
-    server: {
-      host: '0.0.0.0',
-      port: 8113,
-      open: true,
-      strictPort: false,
-      // proxy: {}
-    },
+    root: process.cwd(),
     resolve: {
       alias: {
         "@": resolve(__dirname, "./src"),
@@ -39,7 +18,14 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
         "api": resolve(__dirname, "./src/api"),
       },
     },
-    css: { preprocessorOptions: { css: { charset: false } } },
+    base: mode.command === 'serve' ? './' : '/',
+    hmr: true,
+    server: {
+      host: '0.0.0.0',
+      port: 8113,
+      open: true,
+      strictPort: false,
+    },
     build: {
       outDir: 'dist',
       sourcemap: false,
@@ -64,5 +50,6 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
         }
       }
     },
+    css: { preprocessorOptions: { css: { charset: false } } },
   }
 })