dev.watchFiles
type WatchFiles = {
paths: string | string[];
// watch options for chokidar
options?: WatchOptions;
};
Watch files and directories for changes. When a file changes, the page will be reloaded.
If both dev.hmr
and dev.liveReload
are set to false, watchFiles
will be ignored.
Example
You can configure a list of globs/directories/files to watch for file changes.
export default {
dev: {
watchFiles: {
// watch a single file
paths: 'public/demo.txt',
// use a glob pattern
paths: 'src/**/*.txt',
// watch multiple file paths
paths: ['src/**/*.txt', 'public/**/*'],
},
},
};
You can also specify chokidar watcher options by passing an object with paths
and options
properties.
export default {
dev: {
watchFiles: {
paths: 'src/**/*.txt',
options: {
usePolling: false,
},
},
},
};