vite 别名配置注意事项
小于 1 分钟约 117 字
vite 别名配置注意事项
- Vite config

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import * as path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://xuanyuan.jinuo.fun:8080/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
});
- Tsconfig.json
告诉 TS 解析如何解析某些路径
注意./src/* 后边这个*
一定要加