VSCode Intellisense 不适用于 webpack + 别名 [英] VSCode Intellisense does not work with webpack + alias

查看:33
本文介绍了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

这篇关于VSCode Intellisense 不适用于 webpack + 别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆