简体   繁体   中英

How to share library within other library nx (nrwl) - singlerepo

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?

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"],
    }
  },
}
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM