latus/template/webpack.config.js
2020-12-07 06:20:30 -06:00

37 lines
1.1 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');
module.exports = new Promise(async (resolve, reject) => {
try {
const config = readConfig();
const paths = Object.entries(config).map(([plugin]) => {
try {
const local = join(process.cwd(), 'src', plugin);
require.resolve(local);
return local;
}
catch (error) {
return plugin;
}
});
const latus = new Latus({
config,
modules: paths.map((path) => require(path)),
});
const configs = {
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);
}
});