Integrate Serverless with nrwl nx

Viewed 428

Im completely new to @nrwl/nx but would like to use it in a fullstack project with react and serverless as the backend pushing functions to a cloud FaaS. Serverless

I see that there are no receipes for this with nx currently. How do I go about creating one for my project. I read the documentation but Im not really sure how it needs to be done. How do I customize nx for this so that invoking

nx serve  api

calls

serverless offline

command to start an offline instance Are there any overrides I can do in workspace.json to achieve this?

1 Answers

Look into https://nx.dev/latest/angular/workspace/run-commands-generator#nrwlworkspacerun-commands. It would be something like this:

   // In workspace.json
    "[your-app]": {
      "root": "apps/[your-app]",
      "sourceRoot": "apps/[your-app]/src",
      "projectType": "application",
      "targets": {
        "serve-offline": {
          "executor": "@nrwl/workspace:run-commands",
          "options": {
            "command": "serverless offline",
            "cwd": "path/to/your/app/folder" # optional
          }
        },
        ...
Related