build: remove file >=25MiB in cf pages

This commit is contained in:
MDLeom 2024-10-27 07:07:19 +00:00
parent b36dea1bde
commit cd34943180
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 9 additions and 7 deletions

View File

@ -79,14 +79,16 @@ const f = async () => {
await mkdir(publicPath, { recursive: true })
await Promise.all(projects.map((project) => { return dl(project) }))
// Cloudflare Pages has maximum file size of 25MiB
const files = await readdir(publicPath)
await Promise.all(files.map(async (file) => {
// cloudflare pages limits file size to 25MB
// compressed (br/gz) files are excluded
if (process.env.CF_PAGES && file.startsWith('phishing-filter') && file.endsWith('.rules')) {
await rm(join(publicPath, file))
}
}))
if (process.env.CF_PAGES) {
await Promise.all(files.map(async (filename) => {
const { size } = await stat(join(publicPath, filename))
if (size >= (25 * 1024 * 1024)) {
await rm(join(publicPath, filename), { force: true })
}
}))
}
}
f()