2 years ago

#63393

test-img

Romel Pérez

Nx incremental build for TypeScript packages in watch mode

There is a Nx workspace using just the Nx core (no plugins) with a few buildable TypeScript packages and one web app (a Next.js app).

All TypeScript packages have the following NPM scripts to build and watch for file changes:

{
  "main": "./build",
  "scripts": {
    "build": "rimraf ./build && tsc -p ./tsconfig.build.json",
    "dev": "npm run build -- --watch"
  },
  ...
}

The web app (Next.js) has dependencies on the packages and uses the following (default) scripts:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  ...
}

Since the workspace packages are incrementally built to be consumed by other packages and apps, how can I run the web app for development and watch/build file changes in the affected packages?

# Using the command like this (where "mywebapp" is the name of the web app)
nx run mywebapp:dev

typescript

nrwl-nx

0 Answers

Your Answer

Accepted video resources