DEV Community

Discussion on: Clean Up Your Imports using Absolute Imports & Alias on React apps (Next.js, CRA, and React-Vite)

Collapse
 
monkeyalex profile image
MonkeyAlex

Great article.
Would it be possible to configure vite to understand absolute path WITHOUT using a prefix like (@)?

My vite project is created as React JS (not TS).

Previously with CRA + WebPack, I was able to specify this:

import Main from "Main";
import MyComponent from "components/level2/MyComponent";
Enter fullscreen mode Exit fullscreen mode

where my jsconfig.json looks like this:

{
  "compilerOptions": {
    "target": "es2020",
    "baseUrl": "src/"
  },
  "exclude": ["node_modules", "build"]
}
Enter fullscreen mode Exit fullscreen mode