mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
Delete 89 files that no live entry imports, drop chart.js, vue-chartjs, @tanstack/vue-table and the FontAwesome runtime, and replace the Vue FontAwesome wrapper with a small SVG component. Limit Tailwind source scanning to the perfect-design components the app bundles. Add the bundle gate script and spec: gzip JS+CSS of dist/assets must stay at or below 324300 bytes.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// Gate scope: gzip (level 9) of every .js and .css in dist/assets, lazy chunks included.
|
|
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { gzipSync } from 'node:zlib'
|
|
|
|
export const LIMIT = 324300
|
|
export const DIST = fileURLToPath(new URL('../dist/assets', import.meta.url))
|
|
|
|
export const hasDist = () => existsSync(DIST)
|
|
|
|
export function totalGzip(dir = DIST) {
|
|
return measure(dir).reduce((n, r) => n + r.gzip, 0)
|
|
}
|
|
|
|
export function measure(dir = DIST) {
|
|
return readdirSync(dir)
|
|
.filter((f) => /\.(js|css)$/.test(f))
|
|
.map((f) => ({ file: f, gzip: gzipSync(readFileSync(join(dir, f)), { level: 9 }).length }))
|
|
.sort((a, b) => b.gzip - a.gzip)
|
|
}
|
|
|
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
const rows = measure()
|
|
const total = totalGzip()
|
|
for (const r of rows.slice(0, 10)) console.log(`${String(r.gzip).padStart(8)} ${r.file}`)
|
|
console.log(`total gzip JS+CSS: ${total} B (limit ${LIMIT}); ${rows.length} files`)
|
|
if (total > LIMIT) {
|
|
console.error('bundle gate FAILED')
|
|
process.exit(1)
|
|
}
|
|
}
|