feat: app webpack
This commit is contained in:
parent
41802a2c9d
commit
86d416737c
55
packages/build/src/build/app.webpack.config.js
Normal file
55
packages/build/src/build/app.webpack.config.js
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
require('source-map-support/register');
|
||||||
|
|
||||||
|
const {Latus, require: R} = require('@latus/core');
|
||||||
|
const neutrino = require('neutrino');
|
||||||
|
|
||||||
|
const {
|
||||||
|
LATUS_ONLY_BUILD = '',
|
||||||
|
LATUS_BABEL_CONFIG = require.resolve('./.babelrc.js'),
|
||||||
|
LATUS_NEUTRINO_CONFIG = require.resolve('./.neutrinorc.js'),
|
||||||
|
} = process.env;
|
||||||
|
const onlyBuilds = LATUS_ONLY_BUILD.split(',').map((name) => name.trim());
|
||||||
|
|
||||||
|
R('@babel/register')({
|
||||||
|
configFile: LATUS_BABEL_CONFIG,
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = process.env.LATUS_LINTING
|
||||||
|
? neutrino(server).webpack()
|
||||||
|
: new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const latus = Latus.create();
|
||||||
|
const configs = {
|
||||||
|
server: require(LATUS_NEUTRINO_CONFIG),
|
||||||
|
};
|
||||||
|
latus.invokeFlat('@latus/core/build', configs);
|
||||||
|
Promise.all(Object.entries(configs).map(async ([k, v]) => [k, await v]))
|
||||||
|
.then(Object.fromEntries)
|
||||||
|
.then((configs) => {
|
||||||
|
const webpackConfigs = Object.values(
|
||||||
|
Object.entries(configs)
|
||||||
|
.reduce(
|
||||||
|
(r, [name, config]) => ({
|
||||||
|
...r,
|
||||||
|
...(
|
||||||
|
(0 === onlyBuilds.length || -1 !== onlyBuilds.indexOf(name))
|
||||||
|
? {[name]: config}
|
||||||
|
: {}
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((config) => neutrino(config).webpack());
|
||||||
|
if (webpackConfigs.length > 1) {
|
||||||
|
resolve(webpackConfigs);
|
||||||
|
}
|
||||||
|
if (1 === webpackConfigs.length) {
|
||||||
|
resolve(webpackConfigs[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user