adrian-altner.de/scripts/copy-sw.js
Adrian Altner 5bb63bacf5
All checks were successful
Deploy / deploy (push) Successful in 49s
Initial commit: Astro 6 static blog site
- German (default) and English i18n support
- Categories and tags
- Blog posts with hero images
- Dark/light theme switcher
- View Transitions removed to fix reload ghost images
- Webmentions integration
- RSS feeds per locale

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-22 10:55:29 +02:00

17 lines
679 B
JavaScript

// Copies sw.js + workbox-*.js from dist/server/ to dist/client/ after build.
// @astrojs/node standalone only serves static files from dist/client/, but
// @vite-pwa/astro generates the service worker into dist/server/ during the
// SSR Vite build pass.
import { copyFile, readdir } from "node:fs/promises";
import { join } from "node:path";
const serverDir = "dist/server";
const clientDir = "dist/client";
const files = await readdir(serverDir).catch(() => []);
for (const file of files) {
if (file === "sw.js" || file.startsWith("workbox-")) {
await copyFile(join(serverDir, file), join(clientDir, file));
console.log(`[copy-sw] ${file} → dist/client/`);
}
}