From cd3494318088e8d0c9457eb87dcfe4c217ceadf0 Mon Sep 17 00:00:00 2001 From: MDLeom <2809763-curben@users.noreply.gitlab.com> Date: Sun, 27 Oct 2024 07:07:19 +0000 Subject: [PATCH] build: remove file >=25MiB in cf pages --- src/build.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/build.js b/src/build.js index 5fd48c4..8714228 100644 --- a/src/build.js +++ b/src/build.js @@ -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()