require('source-map-support/register'); const {Latus, require: R} = require('@latus/core'); const neutrino = require('neutrino'); const server = require('./.neutrinorc'); const { LATUS_ONLY_BUILD = '', LATUS_BABEL_CONFIG = require.resolve('@latus/build/build/.babelrc.js'), } = process.env; const onlyBuilds = LATUS_ONLY_BUILD.split(',').map((name) => name.trim()); R('@babel/register')({ configFile: LATUS_BABEL_CONFIG, }); module.exports = process.env.LATUS_LINTING ? neutrino(server).webpack() : new Promise((resolve, reject) => { try { const latus = Latus.create(); const configs = {server}; latus.invokeFlat('@latus/core/build', configs); 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, ...( (0 === onlyBuilds.length || -1 === onlyBuilds.indexOf(name)) ? {[name]: config} : {} ), }), {}, ) ) .map((config) => neutrino(config).webpack()); if (webpackConfigs.length > 1) { resolve(webpackConfigs); } if (1 === webpackConfigs.length) { resolve(webpackConfigs[0]); } }); } catch (error) { reject(error); } });