0

Folder structure:

--shared
  ---components
  ---states
  ---api-interfaces

I would like to use @lib/api-interfaces within states and components instead: relative path: ../../../foo/xxx/bar/{...}.ts;.

Is there a way to do it?

hackp0int
  • 4,052
  • 8
  • 59
  • 95

2 Answers2

3

You can do this by adding the path to your tsconfig.json located at the root of the project.

{
  "compilerOptions": {
    "rootDir": ".",
    "baseUrl": ".",
    "paths": {
      "@lib/api-interfaces": ["/path/to/shared/api-interfaces.ts"],
    }
  },
}
C.OG
  • 6,236
  • 3
  • 20
  • 38
1
ng g @nrwl/workspace:lib api-interfaces

This way the lib is configured in the tsconfig, nx.json, angular.json and you don't have to manually add it. Caution, this may remove any existing code so backup first.

Alexander
  • 3,019
  • 1
  • 20
  • 24