Webpack resolve.alias does not work with typescript?

前端 未结 7 1165
日久生厌
日久生厌 2020-12-12 21:02

I try to shorten my imports in typescript

from import {Hello} from \"./components/Hello\";

to import {Hello} from \"Hello\";

<
7条回答
  •  北海茫月
    2020-12-12 21:35

    If anyone still have this issue, don't forget to add your folder to the "include" option on tsconfig.json like this:

    {
      "compilerOptions": {
        "sourceMap": true,
        "allowJs": true,
        "baseUrl": "./",
        "paths": {
          "@/*": [
            "src/*"
          ]
        },
        "target": "es5",
        "module": "es2015",
        "moduleResolution": "node",
        "lib": [
          "es2016",
          "dom"
        ]
      },
      "outDir": "./built/",
      "include": [
        "./src/**/*",
        "./tests/**/*"
      ]
    }
    

提交回复
热议问题