Lorraine Ram-El
Lorraine Ram-El

Reputation: 2775

How to add a variables library to NX workspace?

I have a NX workspace with a NestJS API and an Angular client project (see folder structure).

It has an api-interfaces library shared between the Angular client and the API, as appears below:

enter image description here

How can I add another library for constants and variables shared between client and api?

Upvotes: 1

Views: 1074

Answers (1)

Nico Schuck
Nico Schuck

Reputation: 982

You can generate a lib in the same way:

npx nx generate @nx/js:library lib-data

In the prompt you choose jest and tsc, to make it compatible. The new lib contains a lib-data.ts file which you can fill with all your data:

export const max = 5;
export const allowedFormats = ['image/jpeg', 'image/png'];

Just import the lib in the same way like the interface lib. Then you are able to use all exported constants.

Upvotes: 0

Related Questions