Hide .js.map files in Visual Studio Code

后端 未结 12 2156
生来不讨喜
生来不讨喜 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 17:05

    1. Go to preferences > settings

    2. Click on "Edit on settings.json" (It's on the bottom of the image)

    3. Update the object json as you can see in the image. Then save your changes Ctrl + S and that's all.

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

    enter image description here

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

    From the official doc:

    to exclude JavaScript files generated from both .ts and .tsx source files, use this expression:

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

    This is a bit of a trick. The search glob pattern is used as a key. The settings above use two different glob patterns to provide two unique keys but the search will still match the same files.

    UPDATE 10/3/2017: with this trick we have a problem with "search in folder". Please see the issue

    0 讨论(0)
  • I really don't know how this is implemented but for hiding .js files works:

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

    For hiding .js.map files works:

    "**/*.js.map": {"when": "$(basename)"}
    
    0 讨论(0)
  • 2020-11-30 17:07

    John Papa Twitter LINK says use the following:

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

    There is still no official solution for excluding a file glob based on two different conditions. See this issue.

    There is a workaround though, to define two different glob patterns which target the same files:

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

    I found this, If you have standard JS files then these will be hidden too which may not always be what you want. Perhaps this is better as it only hides JS files that match TS files...

    {
        "files.exclude": {
            "**/.git": true,
            "**/.DS_Store": true,
            "**/*.js.map": true,
            "**/*.js": {"when": "$(basename).ts"}
        }
    }
    
    0 讨论(0)
提交回复
热议问题