fe-interview icon indicating copy to clipboard operation
fe-interview copied to clipboard

webpack添加路径别名后,vscode不能智能提示,如何解决?

Open artdong opened this issue 5 years ago • 1 comments

webpack添加路径别名后,vscode不能智能提示,如何解决?

artdong avatar May 08 '20 10:05 artdong

添加jsconfig.json文件

{
    "compilerOptions": {
      "baseUrl": "./",
      "paths": {
        "@app/*": ["app/*"],
        "@components/*": ["app/build/components/*"],
        "@common/*": ["app/build/common/*"],
        "@actions/*": ["app/build/actions/*"],
        "@enums/*": ["app/enums/*"],
        "@styles/*": ["app/build/style/*"]
      },
      "target": "ES6",
      "module": "commonjs",
      "jsx": "react",  // 重要!支持jsx文件,否则jsx文件无法跳转
      "allowSyntheticDefaultImports": true
    },
    "include": [
      "app/**/*"
    ],
    "exclude": ["node_modules"]
  }

注:

path 与 webpack配置的路径别名对应 jsx 支持jsx文件

artdong avatar May 08 '20 10:05 artdong