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 ],
}