-
Notifications
You must be signed in to change notification settings - Fork 96
Pass config directly to Node API #21
Comments
Could you provide an example of what you mean? I'm not sure I fully understand your use case. |
Hey @pago so we are using Webpack's Node API rather than CLI, currently we are creating the configuration on the fly. The reason for this is that we are using Webpack behind an end-point to bundle files together the end-point then passes specific definition files. Post A could be perhaps something like:
Post B could be perhaps something like:
Both examples are extremely crude but I hope you get the gist of the idea. The with this we call;
Now with parallel-webpack it looks like we can only provide a configuration file which would mean that we would need to generate the configuration as a file perhaps in a temp folder which isn't really ideal. Thanks in advance |
That's tricky because its unfortunately not generally possible. We can only do parallel builds because we start new processes and because the webpack configuration can contain class instances, it can't be serialized. As a result, we can't start different processes and pass the actual configuration around. What we essentially do at trivago is to have the configuration configurable through the environment and CLI parameters (there's a bit more that influences the builds but that's the basic idea). So instead of passing a finalized configuration to webpack, we pass configuration to the webpack.config.js which then generates the right configurations for us (returning an array of configs). As far as I know, that is the only way to achieve parallel execution. |
@pago ok thank you I'll close this |
another use case if you are using webpack with a task runner like gulp or broccoli, integration plugins modify webpack config on the fly before passing it to webpack's node API. if you want to replace webpack with parallel-webpack in a plugin, well, you can't 😄 would be nice if parallel config API has a similar API to webpack itself. switching between them would be easier. |
Doing this would allow for a lot more freedom when it comes to configurations, for example depending on when mine is run my config slightly changes meaning that it needs to be a function that can be executed rather than simply required in which causes problems when coming to use this package.
The text was updated successfully, but these errors were encountered: