Improved build process

Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
Romein van Buren 2022-07-09 13:10:08 +02:00
parent 08bb63415c
commit b3fd94b02a
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
4 changed files with 24 additions and 16 deletions

View File

@ -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(),
],
});

View File

@ -11,7 +11,7 @@
</div>
<style>
:global(html, body) {
:global(html), :global(body) {
--radius: 10px;
--tile-bg: #181818;

View File

@ -3,6 +3,7 @@
const { fork } = require('child_process');
const { processOutage } = require('./lib/processoutage');
const buildDashboard = require('./builddashboard');
const { minifyHtml } = require('core/strings');
const guiCluster = 'web service status';
const icons = {
@ -537,7 +538,7 @@ module.exports = {
if (!renderedDashboard) {
renderedDashboard = await buildDashboard();
}
const dashboardHtml = `
const dashboardHtml = minifyHtml(`
<!DOCTYPE html>
<html lang="en">
<head>
@ -550,7 +551,7 @@ module.exports = {
</head>
<body></body>
</html>
`;
`);
res.send(dashboardHtml);
},
},

View File

@ -17,6 +17,7 @@
},
"homepage": "https://github.com/smartyellow/status#readme",
"dependencies": {
"csso": "^5.0.3"
"csso": "^5.0.3",
"rollup-plugin-css-only": "^3.1.0"
}
}