Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to modify chokidar watchOptions with @web/dev-server #2614

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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