feat(node): add support for async webpack configuration (#9641)

This commit is contained in:
Kalarrs Topham 2022-04-01 15:48:31 -07:00 committed by GitHub
parent 10ae4c1154
commit f9223817b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -21,6 +21,20 @@ module.exports = (config, context) => {
};
```
Also supports promises
```typescript
// Utility function for sleeping
const sleep = (n) => new Promise((resolve) => setTimeout(resolve, n));
module.exports = async (config, context) => {
await sleep(10);
return merge(config, {
// overwrite values here
});
};
```
## Add a Loader
To add the `css-loader` to your config, install it and add the rule.

View File

@ -81,12 +81,15 @@ export async function* webpackExecutor(
if (options.generatePackageJson) {
generatePackageJson(context.projectName, projGraph, options);
}
const config = options.webpackConfig.reduce((currentConfig, plugin) => {
return require(plugin)(currentConfig, {
const config = await options.webpackConfig.reduce(
async (currentConfig, plugin) => {
return require(plugin)(await currentConfig, {
options,
configuration: context.configurationName,
});
}, getNodeWebpackConfig(options));
},
Promise.resolve(getNodeWebpackConfig(options))
);
return yield* eachValueFrom(
runWebpack(config).pipe(