2021-12-25 14:39:47 +01:00
|
|
|
const rollup = require('rollup')
|
|
|
|
|
|
|
|
async function writeBundle(bundle, outputOptions) {
|
2024-05-08 13:16:23 +02:00
|
|
|
await bundle.generate(outputOptions)
|
|
|
|
await bundle.write(outputOptions)
|
2021-12-25 14:39:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async function buildInline(conf) {
|
2024-05-08 13:16:23 +02:00
|
|
|
const bundle = await rollup.rollup(conf.inputOptions).catch(err => {
|
|
|
|
throw err
|
|
|
|
})
|
2021-12-25 14:39:47 +01:00
|
|
|
|
2024-05-08 13:16:23 +02:00
|
|
|
await writeBundle(bundle, conf.outputOptions)
|
2021-12-25 14:39:47 +01:00
|
|
|
|
2024-05-08 13:16:23 +02:00
|
|
|
console.log('BUILD CORE ==> Bundling Done 🎉')
|
2021-12-25 14:39:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async function build(options, outputs, outputOptions, inputOptions, inlineConfigs) {
|
2024-05-08 13:16:23 +02:00
|
|
|
const bundle = await rollup.rollup(inputOptions).catch(err => {
|
|
|
|
throw err
|
|
|
|
})
|
|
|
|
|
|
|
|
for (const option of outputs) {
|
|
|
|
await writeBundle(bundle, {
|
|
|
|
...outputOptions,
|
|
|
|
...option
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const conf of inlineConfigs) {
|
|
|
|
await buildInline(conf)
|
|
|
|
}
|
2021-12-25 14:39:47 +01:00
|
|
|
}
|
|
|
|
|
2024-05-08 13:16:23 +02:00
|
|
|
module.exports = build
|