Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Support MultiCompiler / MultiStats #8

Closed
richardscarrott opened this issue Sep 30, 2016 · 7 comments
Closed

Support MultiCompiler / MultiStats #8

richardscarrott opened this issue Sep 30, 2016 · 7 comments

Comments

@richardscarrott
Copy link
Contributor

webpack(config) returns a MultiCompiler if your config is an array of configurations and multiCompiler.plugin('done', multiStats => {}); provides MultiStats meaning this plugin could potentially receive a MultiCompiler instance.

Currently it works well with the MultiCompiler as it only uses the plugin method which is supported on the MultiCompiler.

It falls down however when interfacing with the MultiStats instance as it looks something like this:

{
    stats: [
        Stats,
        Stats
    ]
}

So it would need to get errors and warnings from each of those child Stats instances.

The other problem is it reads DONE Compiled successfully in NaNms because stats.startTime and stats.endTime don't exist on MultiStats, it'd have to be calculated from both of the child stats.

I'm not sure if this is something you want to support as it is possible to simply apply the plugin to both compilers separately but it means stdout will be flushed to twice so I think it would only show the error from one of the compilations, regardless of 'severity'. Also, the build time would only reflect one of the compilations....not sure if there would be any other implications you can think of with this approach?

As an aside, great work on the plugin -- makes all the difference during development!

@richardscarrott
Copy link
Contributor Author

Okay, I've discovered applying the plugin to both compilers separately doesn't really work because the console may read 'DONE' because the most recent compilation succeeded but it obviously doesn't take into account the other compilation which may still be in an error state.

Would you be open to a PR for this?

@geowarin
Copy link
Owner

Hi @richardscarrott, I'll accept any PR with tests 😄
Thanks for taking the time to document this issue!

@geowarin
Copy link
Owner

Fixed in #9

@DylanPiercey
Copy link

What does the config look like to use this with a multi compiler? Do I add the plugin to both compilers?

@richardscarrott
Copy link
Contributor Author

@DylanPiercey you'll need to apply the plugin to the the multi compiler returned from webpack, e.g. https://github.com/60frames/react-boilerplate/blob/master/server/routes/webpack.js#L20

const multiCompiler = webpack([config1, config2]);
multiCompiler.apply(new FriendlyErrorsWebpackPlugin());

@DylanPiercey
Copy link

@richardscarrott awesome - thanks! Gonna try this out now.

@DylanPiercey
Copy link

It works perfectly :D.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants