A thin wrapper around webpack's compiler that provides a friendlier, event-based API with Promises, explicit begin/end/error/invalidate events, and automatic error handling for compilation failures. Version 3.1.1 supports webpack 2, 3, and 4 (webpack >=2.0.0 <5.0.0). Differentiates from raw webpack by rejecting Promises and calling watch handlers with errors when stats contain errors, plus emitting additional lifecycle events like 'begin' and 'invalidate'. Package is stable and mature with no recent releases.
npm install webpack-sane-compilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a webpack compiler, wraps it with sane-compiler, then demonstrates both .run() and .watch() usage with event listeners.
Always handle the error parameter in watch callback; do not ignore it.
Wrap in try/catch or use .catch() to handle rejection. Check err.stats for details.
Consider using webpack's built-in Compiler with hooks or migrate to 'webpackbar' or 'friendly-errors-webpack-plugin' for more modern workflows.
Use webpack version <5.0.0 as per peer dependency. Alternatively, upgrade to a fork that uses hooks.
Add .catch() to handle rejection: compiler.run().catch(err => console.error(err.message, err.stats))