From b3fd94b02afcdab782533249b9cf66d99a610e75 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Sat, 9 Jul 2022 13:10:08 +0200 Subject: [PATCH] Improved build process Signed-off-by: Romein van Buren --- builddashboard.js | 30 ++++++++++++++++++------------ gui/dashboard/app.svelte | 2 +- index.js | 5 +++-- package.json | 3 ++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/builddashboard.js b/builddashboard.js index 25a53d7..15ef7a7 100644 --- a/builddashboard.js +++ b/builddashboard.js @@ -1,37 +1,43 @@ 'use strict'; +const { minify: minifyCSS } = require('csso'); +const { rollup } = require('rollup'); +const commonjs = require('@rollup/plugin-commonjs'); +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'); -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 = { css: '', map: null }; + let cssOutput = ''; try { const bundle = await rollup({ input: __dirname + '/gui/dashboard/index.js', plugins: [ + // Svelte svelte({ - emitCss: false, compilerOptions: { dev: false, generate: 'dom', }, - preprocess: { - style: ({ content }) => { - cssOutput = minifyCSS(content); - return ''; - }, - }, }), + + // Extract CSS + css({ + output: style => cssOutput = minifyCSS(style), + }), + + // Resolve dependencies resolve({ browser: true, dedupe: [ 'svelte' ], }), + + // CommonJS functions commonjs(), + + // Minify terser(), ], }); diff --git a/gui/dashboard/app.svelte b/gui/dashboard/app.svelte index 32855ee..8a1636f 100644 --- a/gui/dashboard/app.svelte +++ b/gui/dashboard/app.svelte @@ -11,7 +11,7 @@