4

What kind of settings can I use in Visual Studio Code to hide certain .js and .map files ?

enter image description here

0

3 Answers 3

18

You probably don't want to blindly hide all .js and .map files, only the ones that are generated from an associated .ts file like you show in your screenshot.

To conditionally hide them, you're going to want to do this instead:

{
  "files.exclude": {
    "**/.git": true,
    "**/.DS_Store": true,
    "**/*.js.map": true,
    "**/*.js": {"when": "$(basename).ts"}
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Where does this go ?
12

You can configure the files.exclude properties in the User Settings.

Add this to your user settings file.

{
  "files.exclude": {
    "**/.git": true,
    "**/.DS_Store": true,
    "**/*.js": true,
    "**/*.js.map": true
  }
}

You can open the settings file from the command pallet (ctrl + shift + p) and searching for settings.

2 Comments

I would still recommend you use tsconfig.json to output the js and sourcemaps to a separate folder, it makes it easier to maintain.
FYI to open the user settings follow this answer: stackoverflow.com/questions/65908987/…
2

If you don't find settings.json in .vs code folder, you may generate it through vs code.

File >> Preferences >> Settings >>

Notice the drop-down on the right side. Click on it and select the workspace settings.

You may paste your json settings.

{
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "**/*.js.map": true,
        "**/*.js": {"when": "$(basename).ts"},
        "**/node_modules/": true, <-- To hide node modules files
        "**/*.spec.ts": true <-- To hide cli generated files
    }
}

Make sure that you save the file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.