vite配置别名

89 阅读1分钟
npm i -D @types/node
// vite.config.ts
import path from 'path'
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }
})
//tsconfig.node.json
 "compilerOptions": {
    "allowSyntheticDefaultImports": true
  },
//tsconfig.json
"compilerOptions":{
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "src/*"
      ]
    }
}