nuckty
RU
All sections →

nuckty-ext-command-serve

Local serving of the built site through nginx with a generated configuration. The nuckty serve and nuckty stop commands.

Type

command — adds the serve and stop commands via env.commands.

What it does

nuckty serve [target] [--port N]:

  1. Selects the target and checks its HTML directory and the build-generated .build/nginx.conf.
  2. Finds nginx in PATH.
  3. Writes .build/nginx-serve.conf for that artifact and port (8080 by default).
  4. Starts nginx in the foreground, listening on 127.0.0.1.

nuckty stop reads .build/nginx.pid, checks the process command and start time twice, and sends kill -QUIT only to the recognized instance. Build cleanup retains the preview PID, runtime configuration and logs. An unrelated, reused or invalid PID is refused without signaling.

The validation extension stops its own vnu daemon after nuckty validate.

Why track the PID

A developer’s machine may also run nginx for the system or other projects. nuckty stop therefore uses the recorded PID and checks process identity before stopping it; a mismatch makes it refuse to terminate the process.

Local serving

Preview uses the core generator for routing, compression, and image selection. Its configuration is generated afresh: build hooks that change nginx.conf and Apache rules are not carried over automatically. Local nginx checks do not certify production hosting configuration.

Without a name, the first target is selected. The port is an integer from 1 to 65535. The command runs in the foreground; run nuckty stop from a second terminal in the same directory. POSIX tools are required; native Windows is not verified.

Development only

Install this extension as a development dependency (devDependency) for local preview. CI can also use it for integration checks against real nginx.

Installation

This example extends the quickstart with the standard nuckty-ext-block-root document handler. Add the new extension to ext in the global config/config-nuckty.ts, retaining the other entries. If you use a custom document handler, keep its registration instead of nuckty-ext-block-root.

Install the prepared package from packages/ in the extracted starter project:

npm install --save-dev ./packages/nuckty-ext-command-serve-1.0.0-beta1.tgz
import { defineNucktyConfig } from 'nuckty';

export default defineNucktyConfig({
    targets: { main: { configDir: 'config/', outDir: 'site/' } },
    ext: ['nuckty-ext-block-root', 'nuckty-ext-command-serve'],
});

It requires nginx in PATH (locally, via Homebrew or a system installation).