Fixed dashboard errors

Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
Romein van Buren 2022-07-09 12:46:59 +02:00
parent 689e858228
commit 08bb63415c
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
4 changed files with 27 additions and 21 deletions

View File

@ -4,27 +4,36 @@ const svelte = require('rollup-plugin-svelte');
const { terser } = require('rollup-plugin-terser');
const { rollup } = require('rollup');
const { default: resolve } = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const { minify: minifyCSS } = require('csso');
async function build() {
let cssOutput = '';
let cssOutput = { css: '', map: null };
try {
const bundle = await rollup({
input: __dirname + '/gui/dashboard/index.js',
plugins: [ svelte({
emitCss: false,
compilerOptions: {
dev: false,
generate: 'dom',
},
preprocess: {
style: ({ content }) => {
cssOutput = minifyCSS(content);
return '';
plugins: [
svelte({
emitCss: false,
compilerOptions: {
dev: false,
generate: 'dom',
},
},
}), resolve(), terser() ],
preprocess: {
style: ({ content }) => {
cssOutput = minifyCSS(content);
return '';
},
},
}),
resolve({
browser: true,
dedupe: [ 'svelte' ],
}),
commonjs(),
terser(),
],
});
const { output } = await bundle.generate({
@ -36,7 +45,7 @@ async function build() {
return {
code: output[0].code,
css: cssOutput,
css: cssOutput.css,
};
}
catch (error) {

View File

@ -1,5 +1,7 @@
import App from './app.svelte';
export default new App({
target: document.body,
document.addEventListener('DOMContentLoaded', () => {
new App({
target: document.getElementsByTagName('body')[0],
});
});

View File

@ -1,6 +1,5 @@
'use strict';
require('svelte/register');
const { fork } = require('child_process');
const { processOutage } = require('./lib/processoutage');
const buildDashboard = require('./builddashboard');
@ -538,7 +537,6 @@ module.exports = {
if (!renderedDashboard) {
renderedDashboard = await buildDashboard();
}
console.log(renderedDashboard);
const dashboardHtml = `
<!DOCTYPE html>
<html lang="en">

View File

@ -3,9 +3,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},