2022-07-08 15:17:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const svelte = require('rollup-plugin-svelte');
|
2022-07-09 09:11:14 +00:00
|
|
|
const { terser } = require('rollup-plugin-terser');
|
2022-07-08 15:17:17 +00:00
|
|
|
const { rollup } = require('rollup');
|
|
|
|
const { default: resolve } = require('@rollup/plugin-node-resolve');
|
2022-07-09 10:46:59 +00:00
|
|
|
const commonjs = require('@rollup/plugin-commonjs');
|
2022-07-08 15:17:17 +00:00
|
|
|
const { minify: minifyCSS } = require('csso');
|
|
|
|
|
|
|
|
async function build() {
|
2022-07-09 10:46:59 +00:00
|
|
|
let cssOutput = { css: '', map: null };
|
2022-07-08 15:17:17 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const bundle = await rollup({
|
|
|
|
input: __dirname + '/gui/dashboard/index.js',
|
2022-07-09 10:46:59 +00:00
|
|
|
plugins: [
|
|
|
|
svelte({
|
|
|
|
emitCss: false,
|
|
|
|
compilerOptions: {
|
|
|
|
dev: false,
|
|
|
|
generate: 'dom',
|
2022-07-08 15:17:17 +00:00
|
|
|
},
|
2022-07-09 10:46:59 +00:00
|
|
|
preprocess: {
|
|
|
|
style: ({ content }) => {
|
|
|
|
cssOutput = minifyCSS(content);
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
dedupe: [ 'svelte' ],
|
|
|
|
}),
|
|
|
|
commonjs(),
|
|
|
|
terser(),
|
|
|
|
],
|
2022-07-08 15:17:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const { output } = await bundle.generate({
|
|
|
|
sourcemap: true,
|
|
|
|
format: 'iife',
|
|
|
|
name: 'app',
|
|
|
|
file: 'public/build/bundle.js',
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
code: output[0].code,
|
2022-07-09 10:46:59 +00:00
|
|
|
css: cssOutput.css,
|
2022-07-08 15:17:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.error('Error while building status dashboard: ', error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = build;
|