New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

webpack-watcher

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-watcher

Webpack compiler wrapper

latest
Source
npmnpm
Version
0.2.3
Version published
Weekly downloads
14
Maintainers
1
Weekly downloads
 
Created
Source

webpack-watcher

Build Status

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 = require('webpack');
var WebpackWatcher = require('webpack-watcher');
var config = require('./path/to/your/webpack.config');

var compiler = webpack(config);

var watcher = new WebpackWatcher(compiler);

watcher.onceDone(function(err, stats) {
  // Called once the current compilation process has completed. If the
  // process has already completed, the function will be called immediately.
  // If a compilation process is already underway, concurrent calls to
  // `onceDone` will stack up until the process completes.
});

watcher.writeAssets(function(err, filenames) {
  // Read the assets from memory and write them to the file system
});

watcher.onDone(function(err, stats) {
  // Called every time the compilation completes
});

watcher.onInvalid(function() {
  // Called whenever the compiler's watcher determines that the bundle
  // needs to be recompiled
});

watcher.onFailed(function(err) {
  // Called if the compilation process failed or produced errors
});

// Run the compilation process once and start the watcher.
// Called automatically by `onceDone`, if `watch: true`
watcher.watch();

// Run the compilation process once.
// Called automatically by `onceDone`, if `watch: false`
watcher.run();

// Force the compiler to invalidate the assets.
watcher.invalidate();

// Close the compiler's watcher
watcher.close();

Configuration

var watcher = new WebpackWatcher(webpack(config), {
  // 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.

FAQs

Package last updated on 11 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts