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
38
web/tools/compress-assets.mjs
Normal file
38
web/tools/compress-assets.mjs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { readdir, readFile, writeFile } from 'node:fs/promises'
|
||||
import { extname, join } from 'node:path'
|
||||
import { promisify } from 'node:util'
|
||||
import {
|
||||
brotliCompress as brotli,
|
||||
constants,
|
||||
gzip as gzipCallback,
|
||||
} from 'node:zlib'
|
||||
|
||||
const brotliCompress = promisify(brotli)
|
||||
const gzip = promisify(gzipCallback)
|
||||
|
||||
await compressDirectory(new URL('../dist/', import.meta.url))
|
||||
|
||||
async function compressDirectory(directory) {
|
||||
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
||||
const path = join(entry.parentPath, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
await compressDirectory(path)
|
||||
continue
|
||||
}
|
||||
if (!['.css', '.html', '.js', '.json', '.svg'].includes(extname(path)))
|
||||
continue
|
||||
const source = await readFile(path)
|
||||
const [brotliOutput, gzipOutput] = await Promise.all([
|
||||
brotliCompress(source, {
|
||||
params: {
|
||||
[constants.BROTLI_PARAM_QUALITY]: 11,
|
||||
},
|
||||
}),
|
||||
gzip(source, { level: 9 }),
|
||||
])
|
||||
await Promise.all([
|
||||
writeFile(`${path}.br`, brotliOutput),
|
||||
writeFile(`${path}.gz`, gzipOutput),
|
||||
])
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue