Appearance
vite 配置
路径别名配置
TIP
需要配置两个文件
tsconfig.json
ts
{
"compilerOptions": {
// ...etc
// ↓ ① add
"paths": {
"~/*": [
"./*"
]
}
},
// ↓ ② add
"include": [
"**/*.ts",
"**/*.tsx"
]
}
vite.config.ts
ts
import { defineConfig } from "vite"
export default defineConfig({
// ...etc
resolve: {
// ↓ add
alias: {
"~/": `${__dirname}/src/`
},
},
})
WARNING
项目中已配置:~/
映射为 /src/