Hide .js.map files in Visual Studio Code

后端 未结 12 2155
生来不讨喜
生来不讨喜 2020-11-30 16:19

I am working on a typescript project in Visual Studio code and would like to hide the .js.map (and maybe even the .js) files from appearing in the

相关标签:
12条回答
  • 2020-11-30 16:48

    Maybe it's better to hide .map and .js files when they match their corresponding .ts file.
    You can do that by copying the following lines in VS User Settings (Preferences > User Settings):

    // Workspace settings
    "files.exclude": {
            "**/*.js":  {"when": "$(basename).ts"},
            "**/*.map": true
     }
    
    0 讨论(0)
  • 2020-11-30 16:55

    In your settings (either user or workspace) there is a setting that you can tweak to hide anything you'd like:

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

    So you can add in the following to hide .js and .js.map files

    "**/*.js": true,
    "**/*.js.map": true
    

    As this other answer explains, most people probably only want to hide .js files when there is a matching .ts file.

    So instead of doing:

    "**/*.js": true
    

    you might want to do:

    "**/*.js": {"when": "$(basename).ts"}
    
    0 讨论(0)
  • 2020-11-30 16:55

    In VS Code go to Code (or File for Windows users) > Preferences > Workspace Settings and add this code snippet:

    {
       "files.exclude": {
          "**/*.js": {"when": "$(basename).ts"},
          "**/*.map": {"when": "$(basename).map"}
       }
    }
    
    0 讨论(0)
  • 2020-11-30 16:58

    Please add the following lines in "User Settings" panel in order to override "Default Settings". You can hide files {basename}.js and {basename}.js.map when you create file as {basename}.ts.

    "files.exclude": {
            "**/*.js": {
                "when": "$(basename).ts"
            },
            "**/*.js.map": {
                "when": "$(basename)"
            }        
        }
    
    0 讨论(0)
  • 2020-11-30 17:04

    Add these settings to your settings.json in your .vscode folder

    // Place your settings in this file to overwrite default and user settings.
    {
        "files.exclude" :{
        "**/.git":true,
        "**/.DS_Store":true,
        "**/*.map":true,
        "**/app/**/*.js":true
    
        }
    }
    

    If the settings.json is not available click on File ---> Preferences --> Workspace Settings.

    0 讨论(0)
  • 2020-11-30 17:05

    When you are working with TypeScript, you often don’t want to see generated JavaScript files in the explorer or in search results. VS Code offers filtering capabilities with a files.exclude setting (File > Preferences > Workspace Settings) and you can easily create an expression to hide those derived files:

    "**/*.js": { "when": "$(basename).ts"}
    

    Similarly hide generated .map files by:

     "**/*.js.map": { "when": "$(basename)"}
    

    So you will have a configuration like in:

    settings.json

    // Place your settings in this file to overwrite default and user settings.
    {
        "files.exclude": {
            "**/*.js": { "when": "$(basename).ts"},
            "**/*.js.map": { "when": "$(basename)"}
        }
    }
    

    Link: https://code.visualstudio.com/docs/languages/typescript#_hiding-derived-javascript-files

    0 讨论(0)
提交回复
热议问题