import { fileURLToPath, URL } from 'node:url' 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' import autoImport from 'unplugin-auto-import/vite' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { VantResolver } from '@vant/auto-import-resolver' const createAutoImport = () => { return autoImport({ imports: ['vue', 'vue-router', 'pinia'], dts: false }) } // https://vitejs.dev/config/ 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)) } }, 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";' } } } } })