Skip to content

Commit

Permalink
feat: Add option to modify chokidar watchOptions with @web/dev-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Matsuuu committed Jan 20, 2024
1 parent 78abb0a commit fa46b6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dev-server-core/src/server/DevServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DevServer {
constructor(
public config: DevServerCoreConfig,
public logger: Logger,
public fileWatcher = chokidar.watch([]),
public fileWatcher = chokidar.watch([], config.chokidarOptions),
) {
if (!config) throw new Error('Missing config.');
if (!logger) throw new Error('Missing logger.');
Expand Down
6 changes: 6 additions & 0 deletions packages/dev-server-core/src/server/DevServerCoreConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Middleware } from 'koa';
import { Plugin } from '../plugins/Plugin';
import { Server } from 'net';
import chokidar from 'chokidar';

export type MimeTypeMappings = Record<string, string>;

Expand Down Expand Up @@ -67,4 +68,9 @@ export interface DevServerCoreConfig {
* Useful when you want more control over when files are build (e.g. when doing a test run using @web/test-runner).
*/
disableFileWatcher?: boolean;

/**
* Additional options you want to provide to chokidar file watcher
*/
chokidarOptions?: chokidar.WatchOptions;
}
1 change: 1 addition & 0 deletions packages/dev-server/src/config/parseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const defaultConfig: Partial<DevServerConfig> = {
clearTerminalOnReload: true,
middleware: [],
plugins: [],
chokidarOptions: {},
};

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

0 comments on commit fa46b6c

Please sign in to comment.