mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 21:47:58 +00:00
Improved build process
Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
parent
08bb63415c
commit
b3fd94b02a
@ -1,37 +1,43 @@
|
|||||||
'use strict';
|
'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 svelte = require('rollup-plugin-svelte');
|
||||||
const { terser } = require('rollup-plugin-terser');
|
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() {
|
async function build() {
|
||||||
let cssOutput = { css: '', map: null };
|
let cssOutput = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const bundle = await rollup({
|
const bundle = await rollup({
|
||||||
input: __dirname + '/gui/dashboard/index.js',
|
input: __dirname + '/gui/dashboard/index.js',
|
||||||
plugins: [
|
plugins: [
|
||||||
|
// Svelte
|
||||||
svelte({
|
svelte({
|
||||||
emitCss: false,
|
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
dev: false,
|
dev: false,
|
||||||
generate: 'dom',
|
generate: 'dom',
|
||||||
},
|
},
|
||||||
preprocess: {
|
|
||||||
style: ({ content }) => {
|
|
||||||
cssOutput = minifyCSS(content);
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Extract CSS
|
||||||
|
css({
|
||||||
|
output: style => cssOutput = minifyCSS(style),
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Resolve dependencies
|
||||||
resolve({
|
resolve({
|
||||||
browser: true,
|
browser: true,
|
||||||
dedupe: [ 'svelte' ],
|
dedupe: [ 'svelte' ],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// CommonJS functions
|
||||||
commonjs(),
|
commonjs(),
|
||||||
|
|
||||||
|
// Minify
|
||||||
terser(),
|
terser(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:global(html, body) {
|
:global(html), :global(body) {
|
||||||
--radius: 10px;
|
--radius: 10px;
|
||||||
--tile-bg: #181818;
|
--tile-bg: #181818;
|
||||||
|
|
||||||
|
5
index.js
5
index.js
@ -3,6 +3,7 @@
|
|||||||
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');
|
||||||
|
const { minifyHtml } = require('core/strings');
|
||||||
|
|
||||||
const guiCluster = 'web service status';
|
const guiCluster = 'web service status';
|
||||||
const icons = {
|
const icons = {
|
||||||
@ -537,7 +538,7 @@ module.exports = {
|
|||||||
if (!renderedDashboard) {
|
if (!renderedDashboard) {
|
||||||
renderedDashboard = await buildDashboard();
|
renderedDashboard = await buildDashboard();
|
||||||
}
|
}
|
||||||
const dashboardHtml = `
|
const dashboardHtml = minifyHtml(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -550,7 +551,7 @@ module.exports = {
|
|||||||
</head>
|
</head>
|
||||||
<body></body>
|
<body></body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`);
|
||||||
res.send(dashboardHtml);
|
res.send(dashboardHtml);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/smartyellow/status#readme",
|
"homepage": "https://github.com/smartyellow/status#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csso": "^5.0.3"
|
"csso": "^5.0.3",
|
||||||
|
"rollup-plugin-css-only": "^3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user