16cad3fe36
- Add sharp dependency for image format conversion - Generate WebP (quality 80) and AVIF (quality 70) variants for all raster images - Render <picture> elements with srcset fallbacks (AVIF > WebP > original) - SVG images remain as <img> without picture wrapper - Update Dockerfile to install libvips for sharp, copy from public/ dir - Add nginx cache rules for .webp and .avif files - Add .gitignore for node_modules, public, dist
36 lines
934 B
JavaScript
36 lines
934 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const distDir = path.join(__dirname, 'dist');
|
|
|
|
// Run build first if dist doesn't exist
|
|
if (!fs.existsSync(distDir)) {
|
|
require('./src/build.js');
|
|
}
|
|
|
|
const indexPath = path.join(distDir, 'index.html');
|
|
if (!fs.existsSync(indexPath)) {
|
|
console.error('FAIL: dist/index.html not found');
|
|
process.exit(1);
|
|
}
|
|
|
|
const html = fs.readFileSync(indexPath, 'utf8');
|
|
const checks = [
|
|
['title', html.includes('<title>Signal Ledger</title>') || html.includes('Signal Ledger')],
|
|
['header', html.includes('Signal Ledger')],
|
|
['footer', html.includes('Signal Ledger is a subsidiary of Jopdorp.') || html.includes('subsidiary of Jopdorp')],
|
|
];
|
|
|
|
let failed = false;
|
|
for (const [name, pass] of checks) {
|
|
if (pass) {
|
|
console.log(`PASS: ${name}`);
|
|
} else {
|
|
console.error(`FAIL: ${name}`);
|
|
failed = true;
|
|
}
|
|
}
|
|
|
|
if (failed) process.exit(1);
|
|
console.log('All tests passed.');
|