2022-07-08 15:17:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { rollup } = require('rollup');
|
2022-07-09 10:46:59 +00:00
|
|
|
const commonjs = require('@rollup/plugin-commonjs');
|
2022-07-09 11:10:08 +00:00
|
|
|
const css = require('rollup-plugin-css-only');
|
|
|
|
const { default: resolve } = require('@rollup/plugin-node-resolve');
|
|
|
|
const svelte = require('rollup-plugin-svelte');
|
|
|
|
const { terser } = require('rollup-plugin-terser');
|
2022-07-08 15:17:17 +00:00
|
|
|
|
2022-07-13 09:03:27 +00:00
|
|
|
async function build() {
|
2022-07-09 11:10:08 +00:00
|
|
|
let cssOutput = '';
|
2022-07-08 15:17:17 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const bundle = await rollup({
|
2022-07-11 13:00:05 +00:00
|
|
|
input: __dirname + '/../../gui/dashboard/index.js',
|
2022-07-09 10:46:59 +00:00
|
|
|
plugins: [
|
2022-07-09 11:10:08 +00:00
|
|
|
// Svelte
|
2022-07-09 10:46:59 +00:00
|
|
|
svelte({
|
|
|
|
compilerOptions: {
|
|
|
|
dev: false,
|
|
|
|
generate: 'dom',
|
2022-07-08 15:17:17 +00:00
|
|
|
},
|
2022-07-09 10:46:59 +00:00
|
|
|
}),
|
2022-07-09 11:10:08 +00:00
|
|
|
|
|
|
|
// Extract CSS
|
2022-07-13 09:03:27 +00:00
|
|
|
css({ output: style => cssOutput = style }),
|
2022-07-09 11:10:08 +00:00
|
|
|
|
|
|
|
// Resolve dependencies
|
2022-07-09 10:46:59 +00:00
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
dedupe: [ 'svelte' ],
|
|
|
|
}),
|
2022-07-09 11:10:08 +00:00
|
|
|
|
|
|
|
// CommonJS functions
|
2022-07-09 10:46:59 +00:00
|
|
|
commonjs(),
|
2022-07-09 11:10:08 +00:00
|
|
|
|
|
|
|
// Minify
|
2022-07-09 10:46:59 +00:00
|
|
|
terser(),
|
|
|
|
],
|
2022-07-08 15:17:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const { output } = await bundle.generate({
|
2022-07-12 09:34:04 +00:00
|
|
|
sourcemap: false,
|
2022-07-08 15:17:17 +00:00
|
|
|
format: 'iife',
|
|
|
|
name: 'app',
|
|
|
|
file: 'public/build/bundle.js',
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2022-07-12 09:34:04 +00:00
|
|
|
map: output[0].map ? output[0].map.toUrl() : '',
|
2022-07-08 15:17:17 +00:00
|
|
|
code: output[0].code,
|
2022-07-13 09:03:27 +00:00
|
|
|
css: cssOutput,
|
2022-07-08 15:17:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.error('Error while building status dashboard: ', error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = build;
|