Search code examples
angularangular-cli

Replace Long Path for a Shortened Path in angular-cli?


I'm using the Angular CLI. How do I convert a path from:

import {AppConfig, AppConfigInterface} from '../../../app.config';

to something like:

import {AppConfig, AppConfigInterface} from 'root/app.config';

Solution

  • try this in tsconfig.json:

      {
      "compileOnSave": false,
      "compilerOptions": {
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
          "node_modules/@types"
        ],
        "lib": [
          "es2017",
          "dom"
        ],
        "paths": {
          "@services/*": ["app/services/*"] // here!
        }
      }
    }