0

Im trying to write my own WebpackPlugin. It works just fine (it moves some generated files, and then combines those).

It listens to the 'done' event of the webpack compiler. But the following happens:

    compiler.plugin('done', (stats) =>
    {
        //dont continue when there were build errors
        if(stats.compilation.errors && stats.compilation.errors.length) return;
        //yet this code gets triggered continously, while webpack only outputs asset information once.
  • the event is triggered once after a succesfull build
  • the event is triggered once after I introduce a code error
  • the event keeps being triggered continuously after I remove the error

The only loader I'm using is ts-loader. Is this normal behaviour I should I seek a resolution by digging into the loader?

Im trying to find a different event, but with emit the exact same thing happens. Also I'm trying to investigate the info in stats to see if I can detect that no new assets or files were created, but can't seem to find it yet.

Any tips?

Flion
  • 10,468
  • 13
  • 48
  • 68
  • You're not checking that the build completed *successfully*. All "done" says is that the build finished. You need to be able to detect a successful build or a failure. – ChrisF Jan 16 '16 at 18:52
  • I'm already checking `stats.compilation.errors`, if there are any errors I dont continue. The problem is that the event keeps being triggered, without errors, yet only the first time webpack itself outputs things in the console, I just don't know how to detect _that_ – Flion Jan 16 '16 at 18:56

0 Answers0