44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
// Whilst the configuration object can be modified here, the recommended way of making
|
|
// changes is via the presets' options or Neutrino's API in `.neutrinorc.js` instead.
|
|
// Neutrino's inspect feature can be used to view/export the generated configuration.
|
|
const {join} = require('path');
|
|
|
|
const {readConfig, Latus} = require('@latus/core');
|
|
const neutrino = require('neutrino');
|
|
|
|
if (process.env.LATUS_LINTING) {
|
|
// eslint-disable-next-line global-require
|
|
module.exports = neutrino(require('./.neutrinorc')).webpack();
|
|
}
|
|
else {
|
|
module.exports = new Promise((resolve, reject) => {
|
|
try {
|
|
const config = readConfig();
|
|
const paths = Object.entries(config).map(([plugin]) => {
|
|
try {
|
|
require.resolve(plugin);
|
|
return plugin;
|
|
}
|
|
catch (error) {
|
|
return join(process.cwd(), plugin);
|
|
}
|
|
});
|
|
const latus = new Latus({
|
|
config,
|
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
modules: paths.map((path) => require(path)),
|
|
});
|
|
const configs = {
|
|
// eslint-disable-next-line global-require
|
|
app: require('./.neutrinorc'),
|
|
};
|
|
latus.invokeFlat('@latus/core/build', configs);
|
|
const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack());
|
|
resolve(webpackConfigs);
|
|
}
|
|
catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
}
|