Search code examples
webpackhookwebpack-dev-serverwebpack-4tap

Webpack-dev-server plugin tap hooks


Under webpack-4's new plugin tap methods, is it possible to hook into a webpack-dev-server build, and obtain build error details?

I've tried both compiler's invalid and compilation's failedModule.

Compiler's invalid seems to work, but only after building twice and only returns a file path. Compilation's failedModule just never gets accessed due to running webpack-dev-server.


Solution

  • You can hook into done and then use the Stats instance.

    It has some useful helpers:

    stats.hasErrors()
    stats.hasWarnings()
    

    The errors and warnings are read from the Compilation instance.