29 lines
626 B
TypeScript
29 lines
626 B
TypeScript
import { defineConfig, loadEnv } from "vite";
|
|
import uni from "@dcloudio/vite-plugin-uni";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({mode, command}) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
const {VITE_API_BASE} = env
|
|
return {
|
|
plugins: [uni()],
|
|
server: {
|
|
port: 6811,
|
|
proxy: {
|
|
'/api': {
|
|
target: VITE_API_BASE,
|
|
changeOrigin: true,
|
|
rewrite: (p) => p.replace(/^\/api/, '')// 正则删除 "/api"
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
api: 'modern-compiler'
|
|
}
|
|
}
|
|
},
|
|
}
|
|
});
|