The .nextwebrc file

Every field of .nextwebrc, what a build always leaves out, and .nextwebignore.

about 4 minutes to read

.nextwebrc tells pkg create how to build a folder into a package, and tells pkg validate what to check. It is a JSON file at the root of the application's folder. The package's name and version come from the command line, pkg create <name> <version>, never from this file.

When the folder has no .nextwebrc, pkg create writes a starter one from what it finds there and stops, so we can review it before anything is built. For the Node.js application in the Package lesson it wrote:

hello/.nextwebrc
{
  "type": "application",
  "distribution": "internal",
  "runtime": "node",
  "site": {
    "entry": "app.js",
    "verify": {
      "path": "/",
      "statusCode": 200
    }
  },
  "encrypt": {
    "source": []
  },
  "validate": {
    "endpoints": [
      {
        "path": "/",
        "status": 200
      }
    ]
  }
}

A field Nextweb does not know is refused, so a typo is an error and not a setting that is quietly ignored.

Fields

Field What it says When it is left out
owner The account or organization the package is built for, by its handle. The package name starts with it. Our own account
type application, library, or service application
category The folder under nextweb_server/pkg/ that the package installs into app, library, or service, from type
runtime What runs it. deploy runs node applications as sites. The starter writes php8.3 for a PHP folder, which cannot be deployed as a site yet. deploy cannot run it as a site
site How to run it as a website: entry is the file Nextweb starts, and verify is what verify <site> checks deploy starts the main file from package.json, or app.js, and verify asks for /
include The files to build from, as paths or globs, such as ["app.js", "lib/**"] The whole folder, less what is always left out (below)
requires Packages that must be installed with it, by name None
kernel The Nextweb versions it is meant for, as a range such as >=1.0.0-rc2. It is recorded in the package; installing does not check it yet. Any version
encrypt { "source": [...] }: the files, as paths or globs, to encrypt inside the package. The account needs source encryption granted first. Nothing is encrypted
distribution internal installs only on the owner's licenses, and for an organization on its members' licenses and linked servers. public installs anywhere, and only accounts allowed to publish publicly can use it. internal
validate What pkg validate checks before we publish (below) Its built-in checks only

hooks, commands, and verification are for Nextweb's own packages. A package built for an account cannot carry install hooks yet: pkg create refuses a build whose files include a hooks/ folder of scripts.

site

"site": {
  "entry": "app.js",
  "verify": { "path": "/health", "statusCode": 200, "marker": "ok" }
}
  • entry is a path inside the folder. Nextweb runs it as the main module; Your application on Nextweb says what it is given.
  • verify.path starts with /. statusCode is the status it must answer with, 200 when left out. marker, when given, is text the page must contain.

validate

"validate": {
  "endpoints": [{ "path": "/", "status": 200, "contains": "Hello" }],
  "steps": [{ "name": "the package is listed", "command": "pkg info example-hello", "expect": { "outputContains": "example-hello" } }],
  "platforms": ["ubuntu-24.04"],
  "timeout": 600
}

pkg validate always checks the built file itself: its header, that our license can unlock it, and what is inside it. endpoints and steps are checked in a fresh virtual machine for each name in platforms: it installs the package, deploys the site, requests each endpoint, and runs each step. With no platforms listed, pkg validate stops after its own checks, unless it is run with --vm. timeout is the time in seconds each machine may take, from 10 to 7200, and 600 when left out.

  • An endpoint has a path starting with /, the status it must answer with (200 when left out), and optionally text it must contain.
  • A step has a name and a command, or a list of commands, run as Nextweb commands. expect can name the exitCode and text the output outputContains; with neither, every command must succeed.

What is always left out

The build never includes:

  • node_modules, .git, .nextweb-cache, and .nextweb-pkg folders, at any depth;
  • dist, nextweb_server, and verification-reports at the top of the folder;
  • .env files, log files, private keys, and the credential files of common tools such as .npmrc, .aws/, and .ssh/, whatever include says.

Files named like secrets, such as credentials.json, are built in, and pkg create names them so we can check. .gitignore is not read: a file git ignores is still built in.

When the application's package.json lists dependencies, the package carries its node_modules, because nothing installs them on the server. Run npm install --omit=dev in the folder before pkg create.

.nextwebignore

To leave out more, list it in .nextwebignore at the root of the folder, one pattern per line, the way .gitignore is written. Lines starting with # are comments.

hello/.nextwebignore
notes/
*.psd
test/fixtures/large/

A bare name such as *.psd matches at any depth. A pattern with a / at the start or in the middle, such as test/fixtures/large/, matches from the top of the folder, and a / at the end matches folders only. A line starting with ! stops the build: nothing listed here can be put back. To name exactly what goes in instead, use include.