Skip to content

Commit fa46b6c

Browse files
committed
feat: Add option to modify chokidar watchOptions with @web/dev-server
1 parent 78abb0a commit fa46b6c

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/dev-server-core/src/server/DevServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class DevServer {
1818
constructor(
1919
public config: DevServerCoreConfig,
2020
public logger: Logger,
21-
public fileWatcher = chokidar.watch([]),
21+
public fileWatcher = chokidar.watch([], config.chokidarOptions),
2222
) {
2323
if (!config) throw new Error('Missing config.');
2424
if (!logger) throw new Error('Missing logger.');

packages/dev-server-core/src/server/DevServerCoreConfig.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Middleware } from 'koa';
22
import { Plugin } from '../plugins/Plugin';
33
import { Server } from 'net';
4+
import chokidar from 'chokidar';
45

56
export type MimeTypeMappings = Record<string, string>;
67

@@ -67,4 +68,9 @@ export interface DevServerCoreConfig {
6768
* Useful when you want more control over when files are build (e.g. when doing a test run using @web/test-runner).
6869
*/
6970
disableFileWatcher?: boolean;
71+
72+
/**
73+
* Additional options you want to provide to chokidar file watcher
74+
*/
75+
chokidarOptions?: chokidar.WatchOptions;
7076
}

packages/dev-server/src/config/parseConfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const defaultConfig: Partial<DevServerConfig> = {
1616
clearTerminalOnReload: true,
1717
middleware: [],
1818
plugins: [],
19+
chokidarOptions: {},
1920
};
2021

2122
function validate(config: Record<string, unknown>, key: string, type: string) {

0 commit comments

Comments
 (0)