'use strict' import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import VueDevTools from 'vite-plugin-vue-devtools' import path from 'path' const pathResolve = (dir) => { // eslint-disable-next-line no-undef return path.resolve(__dirname, dir) } export default ({ mode }) => { // const env = loadEnv(mode, process.cwd()) // 获取.env文件里定义的环境变量 // console.log(env); //变量在命令行里打印出来 return defineConfig({ plugins: [vue(), VueDevTools()], server: { host: '127.0.0.1', port: 7005, hmr: true, proxy: { // 跨域设置,在后端已经设置 // '/api': { // target: env.VITE_API_BASE_URL, // changeOrigin: true, // rewrite: (path) => { // console.log(path) // return path // }, // } } }, resolve: { alias: { '@': pathResolve('src') } }, css: { preprocessorOptions: { scss: { api: 'modern-compiler', // 或 "modern","legacy" importers: [ // ... ], }, }, }, }) }