Fix and enhance the concrete calculation
Minify the about.css file
This commit is contained in:
fraxle
2026-05-19 10:51:39 +01:00
parent ab9cccd38d
commit ffacb81ab2
7 changed files with 239 additions and 42 deletions
+16 -5
View File
@@ -38,6 +38,7 @@ function cleanDist() {
path.join(DIST, 'index.html'),
path.join(DIST, 'about.html'),
path.join(ASSETS, '_tmp_flat.css'),
path.join(ASSETS, 'about.min.css'),
];
for (const f of targets) {
try { fs.unlinkSync(f); } catch (_) { /* ok if missing */ }
@@ -145,12 +146,22 @@ async function build() {
console.log(' -> ' + htmlFile);
}
// 5. Copy standalone CSS files that are not part of the main bundle
for (const f of ['about.css']) {
const src = path.join(ROOT, 'assets', f);
// 5. Minify standalone CSS files that are not part of the main bundle
// src name -> output name
const standaloneCSS = [['about.css', 'about.min.css']];
for (const [srcName, outName] of standaloneCSS) {
const src = path.join(ROOT, 'assets', srcName);
if (fs.existsSync(src)) {
copyFile(src, path.join(ASSETS, f));
console.log(' -> assets/' + f);
fs.mkdirSync(ASSETS, { recursive: true });
await esbuild.build({
entryPoints: [src],
bundle: false,
minify: true,
outfile: path.join(ASSETS, outName),
logLevel: 'warning',
});
const sz = fs.statSync(path.join(ASSETS, outName)).size;
console.log(' -> assets/' + outName + ' (' + (sz / 1024).toFixed(1) + ' KB minified)');
}
}