在Visual Studio Code中隐藏.js.map文件

本文翻译自:Hide .js.map files in Visual Studio Code

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 file explorer. 我正在Visual Studio代码中的打字稿项目上工作,并希望隐藏.js.map (甚至可能是.js )文件,以免它们出现在文件资源管理器中。

Is it possible to display only the .ts files in the file explorer? 是否可以在文件资源管理器中仅显示.ts文件?


#1楼

参考:https://stackoom.com/question/28XT3/在Visual-Studio-Code中隐藏-js-map文件


#2楼

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.js.map文件

"**/*.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. 正如另一个答案所解释的那样 ,大多数人可能只想在存在匹配的.ts文件时隐藏.js文件。

So instead of doing: 因此,与其做:

"**/*.js": true

you might want to do: 您可能想做:

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

#3楼

I found this, If you have standard JS files then these will be hidden too which may not always be what you want. 我发现,如果您有标准的JS文件,那么这些文件也将被隐藏,而这些文件可能并不总是您想要的。 Perhaps this is better as it only hides JS files that match TS files... 也许更好,因为它只隐藏与TS文件匹配的JS文件...

{
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true,
        "**/*.js.map": true,
        "**/*.js": {"when": "$(basename).ts"}
    }
}

#4楼

I really don't know how this is implemented but for hiding .js files works: 我真的不知道这是如何实现的,但是隐藏.js文件的工作原理是:

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

For hiding .js.map files works: 用于隐藏.js.map文件的方法如下:

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

#5楼

Maybe it's better to hide .map and .js files when they match their corresponding .ts file. .map.js文件与相应的.ts文件匹配时,最好隐藏它们。
You can do that by copying the following lines in VS User Settings (Preferences > User Settings): 您可以通过在“ VS用户设置”(“首选项”>“用户设置”)中复制以下行来做到这一点:

// Workspace settings
"files.exclude": {
        "**/*.js":  {"when": "$(basename).ts"},
        "**/*.map": true
 }

#6楼

When you are working with TypeScript, you often don't want to see generated JavaScript files in the explorer or in search results. 使用TypeScript时,通常不希望在资源管理器或搜索结果中看到生成的JavaScript文件。 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: VS Code提供了具有files.exclude设置( 文件>首选项>工作区设置)的过滤功能,您可以轻松创建一个表达式来隐藏这些派生文件:

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

Similarly hide generated .map files by: 同样,通过以下方式隐藏生成的.map文件:

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

So you will have a configuration like in: 因此,您将具有如下配置:

settings.json 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 链接: https//code.visualstudio.com/docs/languages/typescript#_hiding-derived-javascript-files

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值