Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use intellisense with at symbol ('@') in Vite?

Using a Vite app I can include this in my vite.config.js:

resolve: {
    alias: {
        "@": path.resolve(__dirname, "./src"),
    },
},

which allows me to use the '@' symbol (at character) for path names. This lets me have imports that look like this:

import Home from "@/pages/Home.vue";

As opposed to this:

import Home from "../../../pages/Home.vue";

The problem is that intellisense won't show up in any meaningful way when using the '@' path but it will when I use the '..' path. How do I enable path intellisense starting with '@'

Pictures to clarify what I mean by "intellisense won't show up in any meaningful way when using the '@' path": Using '..' path

Using '@' path

like image 375
Doug Rowe Avatar asked Dec 13 '25 15:12

Doug Rowe


1 Answers

You also need to tell vscode with jsconfig.json or tsconfig.json file, for example:

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "es6",
    "paths": {
      "@/*": ["./src/*"],
    }
  }
}
like image 159
Hoàng Huy Khánh Avatar answered Dec 15 '25 12:12

Hoàng Huy Khánh