2017-01-06 22 views
5

Tôi đang sử dụng CLI góc. Làm thế nào để chuyển đổi một đường dẫn từ:Làm thế nào để tạo ra một "bí danh" cho một con đường dài trong angular-cli?

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

một cái gì đó như:

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

Bản sao có thể có của [Tránh đường dẫn tương đối trong CLI góc] (http://stackoverflow.com/questions/41460810/avoiding-relative-paths-in-angular-cli) – jonrsharpe

Trả lời

3

thử điều này trong 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

góc cli module mặc định thư mục được định nghĩa trong /angular-cli.json bạn có thể thử '/app.config' nếu bạn cần vào thư mục gốc

Các vấn đề liên quan