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()