Deploy #

KawaPress builds a set of static files that can be published by any static hosting service. The deployed site does not need KawaPress or a Node.js server at runtime.

Build and Check Locally #

KawaPress requires Node.js 22.12 or later. Start with a production build:

Shell
npm run docs:build

The build output is written to dist/ in the site root. Before uploading it, inspect the production output locally:

Shell
npm run docs:preview

The preview server runs at http://localhost:4173 by default. It serves the generated dist/ directory, so it reflects the deployable build rather than the development server.

If that port is taken, pick another one with --port:

Shell
kawapress preview --port 5000

The preview server honours the configured base as well. It serves dist/ under that path and redirects / to it, which lets you check how a subpath deployment behaves before you upload anything.

Set the Public Base Path #

No base is needed when the site is deployed at the domain root. If the final URL includes a subpath such as https://example.com/handbook/, set base to /handbook/:

TypeScript
import { nagi } from 'kawapress/nagi'

export default nagi({
  base: '/handbook/',
})

base applies to static assets, the client router, root-relative internal links, and locale entry points. It must match the deployed path and be known before the build starts. See Routing for the mapping between URLs and Markdown files.

Configure Static Hosting #

If the hosting platform builds and deploys from source, configure it to use Node.js 22.12 or later, install dependencies from the lockfile, run docs:build from package.json, and publish the generated dist/ directory.

If the build already runs locally or in a separate CI job, send the complete contents of dist/ to the hosting platform. The deployed site does not need a Node.js runtime.

KawaPress generates a separate HTML file for every page. For example, /guide/routing maps to dist/guide/routing.html. The static server must support extensionless access and follow these rules:

  • Return dist/404.html when no page exists.
  • Do not send every unknown path to index.html; KawaPress is not a single-entry SPA build.

Supported Browsers #

Site styles use the CSS light-dark() function for both the light and the dark appearance, so readers need a browser released in May 2024 or later: Chrome and Edge 123, Firefox 120, Safari 17.5, or newer. Older browsers still open pages and show the text, but some colors may be missing.

Configure Caching #

Generated assets use content-hashed filenames and can be cached for a long time:

FilesRecommended Cache-Control
dist/assets/*public, max-age=31536000, immutable
HTML and 404.htmlUse a short cache or require revalidation

HTML points to the latest hashed assets. Keeping HTML fresh while caching assets/ for a long time gives fast repeat visits without delaying new releases.

Edit this pageLast updated:

Comments