识别vite别名路径方法
1、vite.config.js 修改
在vie.config.js
一级目录下添加一下配置
resolve: {
// alias: [{ find: /^~/, replacement: "" }],
alias: {
"~": path.resolve(__dirname, "./"),
"@": path.resolve(__dirname,"./src")
},
extensions:[".ts",".js",".vue",".json"]
},
2、tsconfig.json
修改
在compilerOptions
下添加配置
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"~/*": ["./*"]
},