ng7 設定檔案路徑別名
阿新 • • 發佈:2019-01-06
/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";