webpack-watcher
A wrapper around webpack compilers which:
- improves performance by writing assets to an in-memory filesystem
- provides a callback interface to detect when:
- the compilation process has completed
- the compiled assets have been invalidated by a plugin (for example: webpack's file watcher)
- the compilation process has failed and/or encountered errors
Basic usage
var webpack = ;var WebpackWatcher = ;var config = ; var compiler = ; var watcher = compiler; watcher; watcher; watcher; watcher; watcher; // Run the compilation process once and start the watcher.// Called automatically by `onceDone`, if `watch: true`watcher; // Run the compilation process once.// Called automatically by `onceDone`, if `watch: false`watcher; // Force the compiler to invalidate the assets.watcher; // Close the compiler's watcherwatcher;
Configuration
var watcher = // Defaults // -------- // Indicates that your source files should be watched for changes watch: true // The delay between a change being detected and the restart // of the compilation process watchDelay: 200 // Reduces the overhead of background compilation by forcing // the compiler to write to an in-memory filesystem. useMemoryFS: true;
This codebase is heavily indebted to webpack-dev-middleware.