Skip to content
目录

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/

好大夫互联网科技(广州)有限公司.