This project was generated using Nx.
๐ Smart, Extensible Build Framework
This project setup was created by executing folling steps
-
install nx globally
npm i nx
-
initialize new nx workspace with default react-app
npx create-nx-workspace@latest nx-nestjs-react-starter
-
use package manager of choice to install dependency for NestJS
yarn add -D @nrwl/nest
npm install -D @nrwl/nest
-
add a new nestjs app to the workspace
npx nx g @nrwl/nest:app api --frontendProject=client
-
add a shared library
nx g @nrwl/node:library mylib
support linting and testing for all applications at once
"test": "npx nx run-many --all --target=test --parallel"
"lint": "nx workspace-lint && npx nx run-many --all --target=lint --parallel"
add separate run & build scripts for backend and frontend
"start:client": "nx run client:serve"
"start:api": "nx run api:serve"
Nx supports many plugins which add capabilities for developing different types of applications and different tools.
These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
- React
npm install --save-dev @nrwl/react
- Nest
npm install --save-dev @nrwl/nest
- Node
npm install --save-dev @nrwl/node
There are also many community plugins you could add.
Run nx g @nrwl/react:app my-app
to generate an application.
You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.
Run nx g @nrwl/react:lib my-lib
to generate a react library.
Run nx g @nrwl/node:library mylib
to create a new node library.
You can also use any of the plugins above to generate libraries as well.
Libraries are shareable across libraries and applications. They can be imported from @nx-nestjs-react-starter/mylib
.
Run nx serve client
for a frontend dev server. Navigate to http://localhost:4200/.
Run nx serve api
for a backend dev server. Navigate to http://localhost:3333/api.
The app will automatically reload if you change any of the source files.
Run nx g @nrwl/react:component my-component --project=my-app
to generate a new component.
Run nx build api
or nx build client
respectively to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run nx test api
or nx test client
to execute the unit tests via Jest.
Run nx affected:test
to execute the unit tests affected by a change.
Run ng e2e client
to execute the end-to-end tests via Cypress.
Run nx affected:e2e
to execute the end-to-end tests affected by a change.
Run nx dep-graph
to see a diagram of the dependencies of your projects.
Visit the Nx Documentation to learn more.