Alias Paths in Ionic 4
1 min readJul 12, 2020
Here is how I load my files without having those long paths => ‘…/…/…/…/folder’
Go to tsconfig.json and add your paths
"compilerOptions": {
"baseUrl": "./",
......... "paths": {
"@app/*": ["src/app/*"],
"@environments/*": ["src/environments/*"],
}
},
For example in my _helpers folder I have
index.ts // This file is important
http.interceptor.ts
jwt.interceptor.ts
app.initializer.ts
.....
Index.ts has the following code;
export * from './app.initializer';
export * from './jwt.interceptor';
export * from './http.interceptor';
....
To load them now without the long path name is easy and quick.
So this…
import { JwtInterceptor } from './../../_helpers/jwt.interceptor';
import { HttpInterceptor } from './../../_helpers/http.interceptor';
......
Becomes …
import { JwtInterceptor, HttpInterceptor } from '@app/_helpers';
Happy coding :)