使用的v3 ts vite
vite.config.ts文件
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import h5ProdEffectPlugin from 'uni-vite-plugin-h5-prod-effect'
// https://vitejs.dev/config/
export default defineConfig({
// base: './',
plugins: [
uni(),
// 对h5 production环境打包时的特殊处理,否则uni-crazy-router在这个环境会异常
h5ProdEffectPlugin(),
],
server: {
port: 8080,
proxy: {
// 跨域代理
'/api': {
target: 'http://localhost:5005',
// target: 'https://192.168.1.14:5005',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "@/style/color.scss";`,
},
},
},
resolve: {
extensions: ['.js'],
},
})