VSCode Intellisense does not work with webpack + alias

前端 未结 2 2049
旧时难觅i
旧时难觅i 2020-12-16 10:32

I have a project using babel alias:

resolve: {
  alias: {
      vue: \'vue/dist/vue.js\',
      \'@cmp\': resolve(\'src/components\'),
      \'@service\': re         


        
相关标签:
2条回答
  • 2020-12-16 11:28

    This worked for me, as suggested here (I wanted @/ to resolve to ./src/):

    {
      "compilerOptions": {
        "target": "es2017",
        "allowSyntheticDefaultImports": false,
        "baseUrl": "./",
        "paths": {
          "@/*": ["src/*"],
        }
      },
      "exclude": ["node_modules", "dist"]
    }
    

    Minimal version, but I'd leave exclude too:

    {
      "compilerOptions": {
        "baseUrl": "./",
        "paths": {
          "@/*": ["src/*"]
        }
      },
    }
    
    0 讨论(0)
  • 2020-12-16 11:36

    Try creating a jsconfig.json and configuring the paths compiler options

    {
      "compilerOptions": {
        "baseUrl": ".",
        "module": "commonjs",
        "paths": {
          "@cmp/*": ["./src/components/*"]
        }
      }
    }
    

    You can find more information about paths and other compiler options here

    0 讨论(0)
提交回复
热议问题