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

View File

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

View File

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

View File

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