abereghici/rush-monorepo-boilerplate

how to run two or more projects?

Artak-Mkrtchyan opened this issue ยท 5 comments

Hi, Thank you for your articles

if I have monorepo like

  • Client/React-App
  • Client/React-Native-App
  • Server/Nodejs-app

How can I run Client/React-App + Server/Nodejs-app or Client/React-App or Server/Nodejs-app if I don't want to do smt like cd ... & rushx or ect

Should I create a script or I should use common/config/rush/command-line.json ?

because if I use the global command and try to run project 1 and project 2
Screenshot 2021-12-20 at 23 13 19

@Artak-Mkrtchyan I would suggest to use command-line.json to create your commands, the benefit of it is you can run the commands from different folders in your monorepo, so you don't need to run the command from the root.

If you want to start multiple projects, you can use a bulk command. Something like this:

    {
      "name": "start",
      "commandKind": "bulk",
      "summary": "Starts all projects in the repo",
      "description": "Iterates through each project in the repo and runs the 'start' script",
      "enableParallelism": true,
      "safeForSimultaneousRushProcesses": true,
      "ignoreMissingScript": true,
      "ignoreDependencyOrder": true
    },

This command will go through all your packages and will execute the start script. This thing will be done in parallel and will skip the package if there is no start command. (Also you can target only the desired packages with rush start --only @monorepo/react-app --only @monorepo/react-second-app). This might work in multiple cases, but if you're working with react ,you would want to see the errors output from your webpack-dev-server. In this case you can create a command for each project to start it ( also in command-line.json.

{
      "name": "start:react-app",
      "commandKind": "global",
      "summary": "Start the react-app project",
      "safeForSimultaneousRushProcesses": true,
      "shellCommand": "cd apps/react-app && rushx start"
    },
    {
      "name": "start:react-second-app",
      "commandKind": "global",
      "summary": "Start the react-second-app project",
      "safeForSimultaneousRushProcesses": true,
      "shellCommand": "cd apps/react-second-app && rushx start"
    }

So from anywhere in your monorepo you can run rush start:react-app in a terminal and you'll have the output from webpack. Same for the second app : start:react-second-app.

I hope that helps you.

@Artak-Mkrtchyan I have created a branch with those commands, so you can play around to see if that solves your issue.
https://github.com/abereghici/rush-monorepo-boilerplate/tree/start_multiple_projects

Thank you