[英]How can I make VSCode auto complete paths (parses) if I use '@ => ./src/component' in Vite project
In a Vite project my config file is as follow在 Vite 项目中,我的配置文件如下
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
plugins: [vue()],
build: {
outDir: 'public',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src/components'),
'~': path.resolve(__dirname, './src'),
},
},
envDir: './',
envPrefix: 'STO_',
});
VSCode doesn't parse paths starting with @
or ~
so if a file doesn't exists I don't even see the error, and I have bad auto-completion experience. VSCode 不解析以
@
或~
开头的路径,因此如果文件不存在,我什至看不到错误,并且我的自动完成体验很差。
In PhpStorm I think there is a file called phpstorm.config.js
where we can tell the editor how to parse such characters.在 PhpStorm 中,我认为有一个名为
phpstorm.config.js
的文件,我们可以在其中告诉编辑器如何解析这些字符。
System.config({
paths: {
'@/*': './src/components/*',
'~/*': './src/*',
},
});
How can I fix this in VSCode?如何在 VSCode 中解决此问题? Is there a similar approach?
有没有类似的方法?
same approach as with a webpack与 webpack 相同的方法
i configured my tsconfig.json
(or alternatively jsconfig.json
) to re-map the import statements:我配置了我的
tsconfig.json
(或者jsconfig.json
)来重新映射导入语句:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"],
"@/*": ["./src/components/*"]
}
}
}
same answer as https://stackoverflow.com/a/39414291/13278193与https://stackoverflow.com/a/39414291/13278193相同的答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.