latus/template/webpack.config.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-30 06:28:29 -06:00
// 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.
2020-11-30 21:36:18 -06:00
const {join} = require('path');
2020-11-30 06:28:29 -06:00
const {readConfig, Plugins} = require('@latus/core');
const neutrino = require('neutrino');
module.exports = new Promise(async (resolve, reject) => {
try {
const config = readConfig();
2020-11-30 21:36:18 -06:00
const paths = Object.entries(config).map(([plugin]) => {
try {
require.resolve(plugin);
return plugin;
}
catch (error) {
return join(process.cwd(), plugin);
}
});
2020-11-30 06:28:29 -06:00
const plugins = new Plugins({
config,
2020-11-30 21:36:18 -06:00
modules: paths.map((path) => require(path)),
2020-11-30 06:28:29 -06:00
});
const configs = {
app: require('./.neutrinorc'),
};
2020-12-01 02:52:56 -06:00
plugins.invokeFlat('@latus/core/build', configs, config);
2020-11-30 06:28:29 -06:00
const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack());
resolve(webpackConfigs);
}
catch (error) {
reject(error);
}
});