From b88020f42a616f9bf902104e1d3ce5c69a521502 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 23 Mar 2021 00:37:11 -0500 Subject: [PATCH] refactor: handle async --- app/webpack.config.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/app/webpack.config.js b/app/webpack.config.js index 0d1584a..2eb8fc0 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -17,23 +17,27 @@ module.exports = process.env.LATUS_LINTING const latus = Latus.create(); const configs = {server}; latus.invokeFlat('@latus/core/build', configs); - const webpackConfigs = Object.values( - Object.entries(configs) - .reduce( - (r, [name, config]) => ({ - ...r, - ...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}), - }), - {}, + Promise.all(Object.entries(configs).map(async ([k, v]) => [k, await v])) + .then(Object.fromEntries) + .then((configs) => { + const webpackConfigs = Object.values( + Object.entries(configs) + .reduce( + (r, [name, config]) => ({ + ...r, + ...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}), + }), + {}, + ) ) - ) - .map((config) => neutrino(config).webpack()); - if (webpackConfigs.length > 1) { - resolve(webpackConfigs); - } - if (1 === webpackConfigs.length) { - resolve(webpackConfigs[0]); - } + .map((config) => neutrino(config).webpack()); + if (webpackConfigs.length > 1) { + resolve(webpackConfigs); + } + if (1 === webpackConfigs.length) { + resolve(webpackConfigs[0]); + } + }); } catch (error) { reject(error);