I tried the below, but got some errors.
- create a Nx workspace:
npx create-nx-workspace@latest myworkspace
, and select to use Angular CLI - generate angular app:
yarn add --dev @nrwl/angular && yarn ng g @nrwl:angular:app myapp-ng
I can see aangular.json
for the workspace setup similarly as Angular CLI, andyarn start/build
all works - add react capability:
yarn add -D @nrwl/react
- generate another react app:
yarn ng g @nrwl/react:app myapp-react
but I got the below error saying Nx workspace not recognized.
I guess it's trying to find the workspace config instead from workspace.json
(an empty Nx workspace has such setup).
Is this a bug in Nx or is it a supported case to include both Angular and React in one workspace? I can find some blogs/docs about it though...
UPDATE:
Okay, just realized that I made a mistake here :(
At step 4, I was running yarn nx g ...
instead of ng g ...
. Then there's a warning as below when using nx
command in a NG CLI workspace:
yarn nx g @nrwl/react:app react2 --dry-run
yarn run v1.12.3
$ nx g @nrwl/react:app react2 --dry-run
> NX NOTE Nx didn't recognize the command, forwarding on to the Angular CLI.
the react app can actually be created successfully using NG CLI. And, I think the warning makes sense.