Pārlūkot izejas kodu

feat: 修改项目配置

yongCode 5 mēneši atpakaļ
vecāks
revīzija
9b916c2bc9
3 mainītis faili ar 49 papildinājumiem un 35 dzēšanām
  1. 4 0
      .eslintrc.cjs
  2. 2 0
      .gitignore
  3. 43 35
      vite.config.js

+ 4 - 0
.eslintrc.cjs

@@ -3,6 +3,10 @@ require('@rushstack/eslint-patch/modern-module-resolution')
 
 module.exports = {
   root: true,
+  env:{
+    node: true,
+    browser: true
+  },
   'extends': [
     'plugin:vue/vue3-essential',
     'eslint:recommended',

+ 2 - 0
.gitignore

@@ -10,6 +10,8 @@ lerna-debug.log*
 node_modules
 .DS_Store
 dist
+/web
+/web.zip
 dist-ssr
 coverage
 *.local

+ 43 - 35
vite.config.js

@@ -1,6 +1,6 @@
 import { fileURLToPath, URL } from 'node:url'
 
-import { defineConfig } from 'vite'
+import { defineConfig , loadEnv} from 'vite'
 import vue from '@vitejs/plugin-vue'
 import VueDevTools from 'vite-plugin-vue-devtools'
 import VueSetupExtend from 'vite-plugin-vue-setup-extend'
@@ -15,41 +15,49 @@ const createAutoImport = () => {
   })
 }
 // https://vitejs.dev/config/
-export default defineConfig({
-  plugins: [
-    vue(),
-    // VueDevTools(),
-    VueSetupExtend(),
-    createAutoImport(),
-    AutoImport({
-      resolvers: [VantResolver()]
-    }),
-    Components({
-      resolvers: [VantResolver()]
-    })
-  ],
-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url))
-    }
-  },
-  server: {
-    host: true,
-    proxy: {
-      '/dev-api': {
-        target: 'http://172.16.10.61:8080',
-        // target: 'https://vue.ruoyi.vip/prod-api',
-        changeOrigin: true,
-        rewrite: (p) => p.replace(/^\/dev-api/, '')
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, process.cwd());
+console.log(env)
+  return {
+    base: mode === 'development' ? '/' : '/web',
+    build: {
+      outDir: 'web'
+    },
+    plugins: [
+      vue(),
+      // VueDevTools(),
+      VueSetupExtend(),
+      createAutoImport(),
+      AutoImport({
+        resolvers: [VantResolver()]
+      }),
+      Components({
+        resolvers: [VantResolver()]
+      })
+    ],
+    resolve: {
+      alias: {
+        '@': fileURLToPath(new URL('./src', import.meta.url))
       }
-    }
-  },
-  //配置sass
-  css: {
-    preprocessorOptions: {
-      scss: {
-        additionalData:
-          '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
+    },
+    server: {
+      host: true,
+      proxy: {
+        '/dev-api': {
+          target: 'http://172.16.10.61:8080',
+          // target: 'https://vue.ruoyi.vip/prod-api',
+          changeOrigin: true,
+          rewrite: (p) => p.replace(/^\/dev-api/, '')
+        }
+      }
+    },
+    //配置sass
+    css: {
+      preprocessorOptions: {
+        scss: {
+          additionalData:
+            '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
+        }
       }
     }
   }