Make VS code read webpack.config and recognize path with alias?

前端 未结 4 824
轻奢々
轻奢々 2020-12-14 00:08

I\'m working with Webpack and Visual Studio Code and in order to avoid things like:

import { AuthenticationService } from \'../../../services/authentication/         


        
4条回答
  •  轮回少年
    2020-12-14 00:44

    Install VSCode extension PathIntellisense .

    To open your VSCode setting file, you can press command+, on macOS(on Windows is ctrl+,), find "a pair of curly brackets button" on the top right corner, click it.

    In my situation, I want to use the symbol @ as an alias of the path ./src . So I add this configuration to my VSCode setting file:

      "path-intellisense.mappings": {
        "@": "${workspaceRoot}/src"
      }
    

    Use ${workspaceRoot} when the path should be relative to the current root of the current project.

    You can find the official example here .


    Original answer:

    I use the VSCode extension PathIntellisense .

    Configure this setting in my VSCode setting file.

    Now VSCode could recognize the path with the alias.

提交回复
热议问题