ng7 设置文件路径别名

/tsconfig.json

配置后重启服务

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2018", "dom"],

    "paths": {
      "~app/*": ["src/app/*"],
      "~shared/*": ["src/app/shared/*"]
    }

  }
}

使用

// import { MSG } from "../../hello";
import { MSG } from "~app/hello";
import { name } from "~shared/shared";
上一篇:runliuv, 安卓查看WIFI密码


下一篇:Linux的五个查找命令find,locate,whereis,which,type