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
|
## Add a Loader
|
||||||
|
|
||||||
To add the `css-loader` to your config, install it and add the rule.
|
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) {
|
if (options.generatePackageJson) {
|
||||||
generatePackageJson(context.projectName, projGraph, options);
|
generatePackageJson(context.projectName, projGraph, options);
|
||||||
}
|
}
|
||||||
const config = options.webpackConfig.reduce((currentConfig, plugin) => {
|
const config = await options.webpackConfig.reduce(
|
||||||
return require(plugin)(currentConfig, {
|
async (currentConfig, plugin) => {
|
||||||
options,
|
return require(plugin)(await currentConfig, {
|
||||||
configuration: context.configurationName,
|
options,
|
||||||
});
|
configuration: context.configurationName,
|
||||||
}, getNodeWebpackConfig(options));
|
});
|
||||||
|
},
|
||||||
|
Promise.resolve(getNodeWebpackConfig(options))
|
||||||
|
);
|
||||||
|
|
||||||
return yield* eachValueFrom(
|
return yield* eachValueFrom(
|
||||||
runWebpack(config).pipe(
|
runWebpack(config).pipe(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user