Zssaer
Zssaer

Reputation: 233

how to set vscode Ctrl+Click go to definition file with alias feature

I used to implement alias feature , like this:

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

but this feature let vscode can't go to definition file by Ctrl+Click. How to fix this?

Upvotes: 7

Views: 5843

Answers (1)

Matt Schlosser
Matt Schlosser

Reputation: 1044

Create or edit a jsconfig.json/tsconfig.json file at the root of your project and add the "paths" option:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Docs

Upvotes: 19

Related Questions