Vetur: webpack aliases doesn't work in a multi-folder workspace

Created on 30 Nov 2019  路  4Comments  路  Source: vuejs/vetur

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ

Info

  • Platform: Windows 10
  • Vetur version: 0.22.6
  • VS Code version: 1.40.2(user setup)

Problem

In a workspace, if the vue project folder is not first place in this workspace, webpack aliases doesn't work, so go to definition can not work.

// jsconfig.json
{
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ],
  "compilerOptions": {
    "checkJs": true,
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./client/*"
      ]
    }
  }
}

Reproducible Case

  1. clone reproduction repo
  2. create a empty folder
  3. create a workspace A , add the reproduction, add the empty folder.
  4. create a workspace B , add the empty folder, add the reproduction.

Now, open Home.vue from workspace A , select Counter and go to definition works. But in workspace B, go to definition doesn't work.

寰俊鍥剧墖缂栬緫_20191130095226
寰俊鍥剧墖缂栬緫_20191130095328

Maybe jsconfig.json not work?

duplicate

Most helpful comment

BTW, the ESLint extension for VSCode has a eslint.workingDirectories option to solve this similar issue.
microsoft/vscode-eslint

All 4 comments

Looks like we have the same problem.
In a workspace setup, vetur autocompletes from the first project jsconfig.json

My setup:

  • app project

    • jsconfig.json

  • ui lib

    • jsconfig.json

In ui lib in any *.vue file I get autocomplete like this: (which is a config from app project)
Screen Shot 2019-12-04 at 10 17 38 AM

However, this works normally for js files (presumably because because i did not configure vetur for js files so regular vscode path works for js files)
Screen Shot 2019-12-04 at 10 18 17 AM

Looks like we have the same problem.
In a workspace setup, vetur autocompletes from the first project jsconfig.json

My setup:

  • app project

    • jsconfig.json
  • ui lib

    • jsconfig.json

In ui lib in any *.vue file I get autocomplete like this: (which is a config from app project)
Screen Shot 2019-12-04 at 10 17 38 AM

However, this works normally for js files (presumably because because i did not configure vetur for js files so regular vscode path works for js files)
Screen Shot 2019-12-04 at 10 18 17 AM

Yep, the js files work well.

BTW, the ESLint extension for VSCode has a eslint.workingDirectories option to solve this similar issue.
microsoft/vscode-eslint

This is the same underlying issue as https://github.com/vuejs/vetur/issues/815. Glad you found a temporary solution.

Was this page helpful?
0 / 5 - 0 ratings