diff --git a/builddashboard.js b/builddashboard.js index a4845d6..25a53d7 100644 --- a/builddashboard.js +++ b/builddashboard.js @@ -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) { diff --git a/gui/dashboard/index.js b/gui/dashboard/index.js index dde0de8..182a1da 100644 --- a/gui/dashboard/index.js +++ b/gui/dashboard/index.js @@ -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], + }); }); diff --git a/index.js b/index.js index 0880d3f..428b4e6 100644 --- a/index.js +++ b/index.js @@ -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 = ` diff --git a/package.json b/package.json index b7e7b43..4cc26c1 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,6 @@ "version": "1.0.0", "description": "", "main": "index.js", - "directories": { - "lib": "lib" - }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" },