latus/template/webpack.config.js

37 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-12-02 19:39:46 -06:00
const {readConfig, Latus} = require('@latus/core');
2020-11-30 06:28:29 -06:00
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 {
2020-12-07 06:20:30 -06:00
const local = join(process.cwd(), 'src', plugin);
require.resolve(local);
return local;
2020-11-30 21:36:18 -06:00
}
catch (error) {
2020-12-07 06:20:30 -06:00
return plugin;
2020-11-30 21:36:18 -06:00
}
});
2020-12-02 19:39:46 -06:00
const latus = new Latus({
2020-11-30 06:28:29 -06:00
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-06 23:37:00 -06:00
latus.invokeFlat('@latus/core/build', configs);
2020-11-30 06:28:29 -06:00
const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack());
resolve(webpackConfigs);
}
catch (error) {
reject(error);
}
});