Night Owl logoNight Owl

Build

Use the build command to generate your site.

In your package.json, add the Night Owl build command to scripts.

{
  "scripts": {
    "build": "night-owl --build"
  }
}

You can now run the build script from the command line.

npm run build

Running a production build

When you run Night Owl’s build command, you may want to transform the files after they are generated.

This might include minifying HTML or purging CSS, for example. These transforms can slow down Night Owl, and are only required when creating a production version of your site.

To check whether a build is in progress, you can use the NIGHTOWL_MODE environment variable supplied by Night Owl. When running a build, this environment variable is set to "build". Otherwise it is set to "watch".

import someMinifier from "someMinifier"

const isBuild = process.env.NIGHTOWL_MODE === "build"

export default {
  transforms: isBuild && [ someMinifier ],
}
Page data

This page was rendered with the following data.

{
  "layout": "_/layouts/docs",
  "menu": {...},
  "filters": {...},
  "helpers": {...},
  "version": "0.5.4",
  "github": "https://github.com/stephenhutchings/night-owl/",
  "npm": "https://www.npmjs.com/package/night-owl",
  "hash": "lmu1z5z4",
  "thumbnail": "https://night-owl.s-ings.com/assets/thumb.png",
  "isDev": false,
  "tags": [ "commands" ],
  "title": "Build",
  "description": "Build your site from templates and other assets",
  "url": "/docs/commands/build/",
  "meta": {
    "url": "/docs/commands/build/",
    "src": "src/docs/02-commands/01-build.md",
    "dist": "dist/docs/commands/build/index.html",
    "collections": {
      "all": [...],
      "intro": [...],
      "commands": [...],
      "configuration": [...],
      "advanced": [...],
      "templates": [...]
    }
  },
  "content": "<p>Use the build command to generate your&nbsp;site.</p>\n<p>In your <code>packag..."
}