aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.3k stars 48 forks source link

baseUrl not working in a fresh vite react-ts project #67

Closed hichemfantar closed 2 years ago

hichemfantar commented 2 years ago

Config below:

{
    "compilerOptions": {
        "target": "ESNext",
        "useDefineForClassFields": true,
        "lib": ["DOM", "DOM.Iterable", "ESNext"],
        "allowJs": false,
        "skipLibCheck": true,
        "esModuleInterop": false,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "module": "ESNext",
        "moduleResolution": "Node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true,
        "jsx": "react-jsx",
        "baseUrl": "./src"
    },
    "include": ["src"],
    "references": [{ "path": "./tsconfig.node.json" }]
}
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [react(), tsconfigPaths()],
});
hichemfantar commented 2 years ago

Forgot to set "allowJs": true