Serve
Use the serve command to run a local server while you work.
In your package.json
, add the Night Owl serve
command to scripts
.
{
"scripts": {
"serve": "night-owl --serve"
}
}
You can now run the serve
script from the command line.
npm run serve
When the local server is running, Night Owl will log the address on the command line.
Combining watch and serve
Usually, you will call serve
and watch
together.
{
"scripts": {
"start": "night-owl --watch --serve"
}
}
Live reloading
When Night Owl detects a change to a template, it will reload the page in the browser.
However, some assets don’t require a full page reload. When images or CSS files change, Night Owl intelligently iterates through the DOM and only reloads the asset that has changed.
Setting the host and port
You can configure which host and port to use in your Night Owl configuration.
The default host is set to "0.0.0.0"
, which allows access to all devices on the local network. The default port is 8080
.
export default {
// Use a different port
port: 3000,
// Disallow access over the local network
host: "127.0.0.1",
}
If the port is unavailable, Night Owl will increment the port number a handful of times to find one that is free to use.