latus/template/webpack.config.js
2020-12-01 02:52:56 -06:00

36 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, Plugins} = 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 {
require.resolve(plugin);
return plugin;
}
catch (error) {
return join(process.cwd(), plugin);
}
});
const plugins = new Plugins({
config,
modules: paths.map((path) => require(path)),
});
const configs = {
app: require('./.neutrinorc'),
};
plugins.invokeFlat('@latus/core/build', configs, config);
const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack());
resolve(webpackConfigs);
}
catch (error) {
reject(error);
}
});