安装依赖
npm install --save-dev @types/node
配置vite.config.ts文件
// vite.config.ts
import { defineConfig } from 'vite';
import { resolve } from 'path';
export default defineConfig({
resolve: {
alias: {
'/@/': resolve(__dirname, './src'),
},
},
});
上面的代码已经配置了路径别名,我们使用ts,还需要配置
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"/@/*": ["src/*"]
}
}
}
标签:uniapp,resolve,ts,别名,vue3,import,vite
From: https://www.cnblogs.com/code-R/p/17564920.html