feat(node): add support for async webpack configuration (#9641)
This commit is contained in:
parent
10ae4c1154
commit
f9223817b3
@ -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.
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user