Steve
Steve

Reputation: 14912

Path completion for assets folder in Visual Studio Code project

VS Code (I'm using Insiders 1.38) works perfectly with path intellisense for imports in a Typescript file such as import { SharedModule } from '../shared/shared.module'; as typing ../ immediately shows me shared and its siblings.

However I'm trying to find a way — which used to work at some point — of getting intellisense for paths within my project, like from my assets folder so I can do

<img src="/assets/images/mobile/touchid.jpg">

When I type the / I get the root of my VS Code project:

enter image description here

If I continue and type the correct root path /assets/ I get:

enter image description here

Where app-heroheader is a simple Angular component in my project.

I have tried the Path Autocomplete and Path Intellisense extensions and get the same result.

Is there no way for me to get path suggestions for /assets/ or assets/?

Upvotes: 1

Views: 4818

Answers (1)

Budhead2004
Budhead2004

Reputation: 614

Path-Intellisense - You can do it with assets/, not /assets/ though, at least that I've been able to figure out.

In your workspace settings.json you can add the following custom mapping:

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

Then when you start typing assets/you'll get the directory.

Example:

enter image description here

Upvotes: 2

Related Questions