2017-01-06 4 views
5

私はAngular CLIを使用しています。以下のようなものにangle-cliで長いパスの "エイリアス"を作成するにはどうすればよいですか?

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

:どのように私はからのパスを変換します

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

[Angular CLIでの相対パスの回避]の可能な複製(http://stackoverflow.com/questions/41460810/avoiding-relative-paths-in-angular-cli) – jonrsharpe

答えて

3

は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! 
 
    } 
 
    } 
 
}

0

角度CLIデフォルトのmodulesディレクトリは、あなたが '/app.config' を試すことができます/angular-cli.json で定義されていますあなたはルートが必要な場合

関連する問題