In this task we'll integrate our first application within the new monorepo.
- Get familiar with integrating apps create configuration within your workspace using the Nx CLI
-
Make sure you can run Nx commands:
- try out
nx --versionand see if it outputs a version number - Pro tip you can add
./node_modules/.binto the$PATHto get all the runnable commandecho "export PATH=./node_modules/.bin:\$PATH" >> ~/.zshrc - You can install
nxglobbaly as well, if you don't mind withnpm i -g nx - if you don't want to install it globally, use can use
bunx nx(if you have bun) ornpx nxinstead ofnx
Please make sure you are using the latest version of Nx (16.1+)
- try out
-
Create a brach for yourself for example:
git checkout -b wip-csabatamas -
Import the
create-react-appbased game-store application to the nx monorepository.- You can find the CRA app here: https://github.com/tamascsaba/cra-game-store
- Use the
repository-integrator.shto integrate to the CRA app to the monorepo./repository-integrator.sh <repoURL> <repoName> <mainBranchName> <codeDestination> <subDirectoryToIntegrate>
-
Lets check the integrated app, it should look similar to this:
-
Run
nx listto see which plugins you have installed -
Add the React plugin:
npm i -S @nx/react -
Use the
@nx/reactplugin to generate an React app calledgame-storein your new workspace⚠️ Important: Make sure you add React Router, select SCSS as a style and use the Vite bundler when asked!Usefull documentation avalible here: https://nx.dev/packages/nx/documents/generate
-
Modify the generated
project.jsonfile and restore the unnecessary overwrites -
Remove the
fetchcall from the application and get the data directly from the mockgetAllGamesPromise -
Serve the app:
nx serve game-store -
See your app live at http://localhost:4200/
-
Inspect what changed from the last time you committed, then commit your changes
Your app should look similar to the screenshot above!
Now we're starting to see some content! But the ratings also don't look that good - we'll fix those in Lab 5.
🎓 If you get stuck, check out the solution
