I'm trying to configure the paths for an Angular 6
library (I have successfully configured the paths for a previous Angular project)
Here is what is working for my previous app in the tsconfig.json
file:
"compilerOptions": {
[...]
"baseUrl": "src",
"paths": {
"@class/*": [ "app/class/*" ],
"@services/*": [ "app/services/*" ],
"@views/*": [ "app/views/*" ]
}
}
and then use it like for example:
Import { Item } from '@class/item';
In my new app I'm trying the same way in the tsconfig.**lib**.json
file:
"compilerOptions": {
[...]
"baseUrl": "src",
"paths": {
"@class/*": [ "lib/class/*" ],
"@services/*": [ "lib/services/*" ],
"@views/*": [ "lib/views/*" ]
}
}
I have tried to import a class in a component for my library like this, but it does not work (VSCode cannot find the file):
Import { Item } from '@class/item';
Note that the import
statement in the main project is working:
Import { Item } from 'myLibrary';
Any idea of what I'm not doing well ?
Thanks for your help.