Slicemachine in monorepo

I have a solution at the moment that isn't ideal but allows me to keep moving forward:

apps/
  site-1/
    package.json
    project.json
    sm.json
    slices/
  site-2/
    ...
  site-3/
    ...

site-1/package.json

This is the hack because Nx allows you to have one package.json at the root but the Slicemachine start script is expecting package.json to be in the same current working directory. (this script I believe)

{
  "devDependencies": {
    "next": "12.x"
  }
}

site-1/project.json

{
  "targets": {
    "slicemachine": {
      "executor": "nx:run-commands",
      "options": {
        "commands": [
          {
            "command": "start-slicemachine"
          }
        ],
        "cwd": "apps/site-1"
      }
    }
  }
}

Now I can run:

$ npx nx run site-1:slicemachine
$ npx nx run site-2:slicemachine
etc.

2 Likes