mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Chore: CDN cache & prefer compare and write
This commit is contained in:
@@ -9,6 +9,7 @@ import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
||||
import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir';
|
||||
import { mkdirp, writeFile } from './lib/misc';
|
||||
import picocolors from 'picocolors';
|
||||
import { compareAndWriteFile } from './lib/create-file';
|
||||
|
||||
const mockDir = path.join(ROOT_DIR, 'Mock');
|
||||
const modulesDir = path.join(ROOT_DIR, 'Modules');
|
||||
@@ -46,6 +47,19 @@ export const buildPublic = task(require.main === module, __filename)(async (span
|
||||
.traceChild('generate index.html')
|
||||
.traceAsyncFn(() => treeDir(PUBLIC_DIR).then(generateHtml));
|
||||
|
||||
await compareAndWriteFile(
|
||||
span,
|
||||
[
|
||||
'/*',
|
||||
' cloudflare-cdn-cache-control: public, max-age=150, stale-while-revalidate=60, stale-if-error=30',
|
||||
'https://:project.pages.dev/*',
|
||||
' X-Robots-Tag: noindex',
|
||||
'/Modules/*',
|
||||
' content-type: text/plain; charset=utf-8'
|
||||
],
|
||||
path.join(PUBLIC_DIR, '_headers')
|
||||
);
|
||||
|
||||
return writeFile(path.join(PUBLIC_DIR, 'index.html'), html);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user