ci(despliegue): fase 5, Dockerfile, nginx, verificaciones y Lighthouse CI
- Dockerfile multi-etapa: build con Playwright (sitio, PDF, precompresión) y nginx sin privilegios en 8080 con healthcheck - nginx: CSP sin unsafe-inline, HSTS, nosniff, Referrer-Policy, caché inmutable para assets con hash, gzip_static, página 404 y /salud - scripts: verificar-prohibidas (falla con PLD, Odoo, lavado, CHM, 115/2026 en dist/), verificar-metricas (falla con resultado sin método), comprimir - Lighthouse CI con umbral 95 en móvil y presupuesto de 1.5 MB / 50 KB de JS - GitHub Actions: check, build, verificaciones, PDF, Lighthouse e imagen Docker Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7fda61dc15
commit
221b2d21a8
14 files changed
+359
-1
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// Precomprime los archivos de texto de dist/ en gzip (.gz) y brotli (.br) para
|
||||
// que nginx los sirva con gzip_static / brotli_static. Uso: node scripts/comprimir.mjs
|
||||
import { readdirSync, readFileSync, writeFileSync, statSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { gzipSync, brotliCompressSync, constants } from 'node:zlib';
|
||||
|
||||
const dist = path.resolve(process.argv[2] ?? 'dist');
|
||||
const TEXTO = new Set(['.html', '.css', '.js', '.mjs', '.xml', '.txt', '.json', '.svg']);
|
||||
let n = 0;
|
||||
function* archivos(dir) {
|
||||
for (const nombre of readdirSync(dir)) {
|
||||
const ruta = path.join(dir, nombre);
|
||||
if (statSync(ruta).isDirectory()) yield* archivos(ruta);
|
||||
else if (TEXTO.has(path.extname(nombre)) && statSync(ruta).size > 1024) yield ruta;
|
||||
}
|
||||
}
|
||||
for (const ruta of archivos(dist)) {
|
||||
const datos = readFileSync(ruta);
|
||||
writeFileSync(ruta + '.gz', gzipSync(datos, { level: 9 }));
|
||||
writeFileSync(ruta + '.br', brotliCompressSync(datos, { params: { [constants.BROTLI_PARAM_QUALITY]: 11 } }));
|
||||
n++;
|
||||
}
|
||||
console.log(`${n} archivos precomprimidos (gz y br)`);
|
||||
Reference in new issue
Block a user