Move browser authentication behind a generated-contract BFF
This commit is contained in:
parent
6f0f20f5cc
commit
fa7220ee33
1 changed files with 7259 additions and 2825 deletions
24
web/tools/check-bundle.mjs
Normal file
24
web/tools/check-bundle.mjs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { readdirSync, statSync } from 'node:fs'
|
||||
import { extname, resolve } from 'node:path'
|
||||
|
||||
const assets = resolve('dist/assets')
|
||||
const limits = new Map([
|
||||
['.js', 256 * 1024],
|
||||
['.css', 64 * 1024],
|
||||
])
|
||||
const totals = new Map()
|
||||
for (const entry of readdirSync(assets)) {
|
||||
const extension = extname(entry)
|
||||
if (!limits.has(extension)) continue
|
||||
totals.set(
|
||||
extension,
|
||||
(totals.get(extension) ?? 0) + statSync(resolve(assets, entry)).size,
|
||||
)
|
||||
}
|
||||
for (const [extension, limit] of limits) {
|
||||
const total = totals.get(extension) ?? 0
|
||||
if (total > limit)
|
||||
throw new Error(
|
||||
`${extension.slice(1).toUpperCase()} bundle is ${total} bytes; limit is ${limit}`,
|
||||
)
|
||||
}
|
||||
Loading…
Reference in a new issue