Travis Webb Travis Webb - 3 months ago 11
Node.js Question

How can I capture the output of a webpack build as a string before it is written to disk?

There seems to be no

output
option in webpack to write the output as a string, either to a nodejs
Buffer
or to
stdout
. Googling has yielded nothing promising. Is this possible, via either configuration or 3rd-party-module?

Answer

After researching, the only way I see to accomplish this would be to monkey-patch webpack's NodeOutputFileSystem.writeFile to capture the string contents.

I ended up using raw babeljs instead of webpack to get the string.