Automatically rebuild a site when files change
190 words, 1-minute read
Setting publican.config.watch
to true
(or any truthy value) keeps Publican running. It watches content and template files and automatically rebuilds the site when changes occur.
Watch mode would normally be used when building a development site (the NODE_ENV
environment variable is set to development
):
publican.config.js
excerpt
// watch in development mode only
const isDev = (process.env.NODE_ENV === 'development');
publican.config.watch = isDev;
By default, Publican waits at least 300 milliseconds to ensure no further files are saved. This can be changed:
publican.config.js
excerpt
// debounce watch for 1 second
publican.config.watchDebounce = 1000;
Shorter watchDebounce
can negatively affect performance because multiple rebuilds are triggered when changing two or more files in a short period of time.
Stop watch mode #
To stop Publican, press Ctrl | Cmd + C in your terminal.