/*
* @Description:
* @Author: 刘洋
* @Date: 2022-07-14 12:06:43
* @LastEditTime: 2022-07-15 15:28:48
* @LastEditors: xxx
*/
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// *********************************** 路径配置新增 start
// node的path ts版本的
import { resolve } from 'path'
// (返回当前路径 + 传入路径)
const pathResolve = (dir: string): any => {
return resolve(__dirname, '.', dir);
};
const alias: Record<string, string> = {
'/@': pathResolve('./src'),
};
// ********************************** 路径配置新增 end
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: { alias },
})
2. 配置 tsconfig.json 的(path 加上就行)
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
发表评论