简体   繁体   English

VSCode导入路径intellisense用于自定义文件扩展名

[英]VSCode import path intellisense for custom files extensions

When writing a code that will be later pushed through webpack, it is possible to use custom loaders for non-standard files. 编写稍后将通过Webpack推送的代码时,可以对非标准文件使用自定义加载程序。 In effect it is possible to write 实际上可以写

import image from './assets/image.png';

and it will be properly handled. 它将得到正确处理。 The problem is VSCode doesn't provide autocompletion for files like .png , .svg , .scss and so on. 问题是VSCode并不像文件提供自动完成.png.svg.scss等。

Is it possible to do so by some settings or an extension? 是否可以通过某些设置或扩展名执行此操作?

I was able to fix it using Path Autocomplete extension. 我能够使用“ 路径自动完成”扩展程序对其进行修复。 By default it does not include file extensions and suggests the .js files in addition to the default suggestions by VS Code. 默认情况下,除了VS Code的默认建议外,它不包含文件扩展名并建议.js文件。 It can be changed by adding the following lines to the User Settings: 可以通过在用户设置中添加以下几行来更改它:

"path-autocomplete.extensionOnImport": true,
"path-autocomplete.excludedItems": {
    "**/*.js": {"when": "**"}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM