Detect `–watch` mode reliably

Hi @sokra. I’m making and I need some way to detect if webpack is working in --watch mode or not (without plugins). I need this because I need to know if I should kill a spawned child_process or not.

Right now I’m doing something like:

function isWatching(compiler) {
    return || === 'MemoryFileSystem';

But in doesn’t seems to work in the latest webpack@beta. Can you please advise some reliable solution?

Right now the only way I see is to use a compiler plugin:

export const WatchModeSymbol = Symbol('WatchMode');

export class DetectWatchPlugin {
    apply(compiler) {
        compiler.plugin("run", function(params, callback) {
            compiler[WatchModeSymbol] = false;

        compiler.plugin("watch-run", function(params, callback) {
            compiler[WatchModeSymbol] = true;

Author: Fantashit

4 thoughts on “Detect `–watch` mode reliably

Comments are closed.