2021-01-05 12:20:20 -06:00
|
|
|
require('source-map-support/register');
|
2021-03-22 02:53:25 -05:00
|
|
|
|
2021-03-23 16:05:57 -05:00
|
|
|
const {Latus, require: R} = require('@latus/core');
|
2021-01-05 12:20:20 -06:00
|
|
|
const neutrino = require('neutrino');
|
|
|
|
|
2021-03-22 02:53:25 -05:00
|
|
|
const server = require('./.neutrinorc');
|
|
|
|
|
|
|
|
const {
|
2021-03-23 11:58:53 -05:00
|
|
|
LATUS_ONLY_BUILD = '',
|
2021-03-23 16:05:57 -05:00
|
|
|
LATUS_BABEL_CONFIG = require.resolve('@latus/build/build/.babelrc.js'),
|
2021-03-22 02:53:25 -05:00
|
|
|
} = process.env;
|
2021-03-23 11:58:53 -05:00
|
|
|
const onlyBuilds = LATUS_ONLY_BUILD.split(',').map((name) => name.trim());
|
2021-03-22 02:53:25 -05:00
|
|
|
|
2021-03-23 16:05:57 -05:00
|
|
|
R('@babel/register')({
|
|
|
|
configFile: LATUS_BABEL_CONFIG,
|
|
|
|
});
|
|
|
|
|
2021-03-22 02:53:25 -05:00
|
|
|
module.exports = process.env.LATUS_LINTING
|
|
|
|
? neutrino(server).webpack()
|
|
|
|
: new Promise((resolve, reject) => {
|
2021-01-05 12:20:20 -06:00
|
|
|
try {
|
|
|
|
const latus = Latus.create();
|
2021-03-22 02:53:25 -05:00
|
|
|
const configs = {server};
|
2021-01-05 12:20:20 -06:00
|
|
|
latus.invokeFlat('@latus/core/build', configs);
|
2021-03-23 00:37:11 -05:00
|
|
|
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,
|
2021-03-23 16:24:57 -05:00
|
|
|
...(
|
|
|
|
(0 === onlyBuilds.length || -1 === onlyBuilds.indexOf(name))
|
|
|
|
? {[name]: config}
|
|
|
|
: {}
|
|
|
|
),
|
2021-03-23 00:37:11 -05:00
|
|
|
}),
|
|
|
|
{},
|
|
|
|
)
|
2021-03-22 02:53:25 -05:00
|
|
|
)
|
2021-03-23 00:37:11 -05:00
|
|
|
.map((config) => neutrino(config).webpack());
|
|
|
|
if (webpackConfigs.length > 1) {
|
|
|
|
resolve(webpackConfigs);
|
|
|
|
}
|
|
|
|
if (1 === webpackConfigs.length) {
|
|
|
|
resolve(webpackConfigs[0]);
|
|
|
|
}
|
|
|
|
});
|
2021-01-05 12:20:20 -06:00
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
});
|