VSCode Intellisense 不适用于 webpack + 别名
问题描述:
我有一个使用 babel 别名的项目:
I have a project using babel alias:
resolve: {
alias: {
vue: 'vue/dist/vue.js',
'@cmp': resolve('src/components'),
'@service': resolve('src/services'),
'@scss': resolve('src/assets/styles'),
}
}
和一个组件:
import someService from '@service/some'
而且智能感知不起作用.与:
And the Intellisense does not work. with:
import someService from '../../../../service/some'
确实如此.
有什么建议吗?
答
尝试创建一个 jsconfig.json 并配置paths
编译器选项
Try creating a jsconfig.json and configuring the paths
compiler options
{
"compilerOptions": {
"baseUrl": ".",
"module": "commonjs",
"paths": {
"@cmp/*": ["./src/components/*"]
}
}
}
您可以找到有关 paths
和其他编译器选项的更多信息 这里
You can find more information about paths
and other compiler options here