adrian-altner.de/scripts/copy-sw.js
Adrian Altner 0f43bb18cc Add deployment scripts for blog, links, notes, photos, and projects; implement history squashing and vision processing
- Created `publish-blog.sh`, `publish-links.sh`, `publish-notes.sh`, `publish-photos.sh`, and `publish-projects.sh` for deploying respective content to the VPS.
- Implemented `squash-history.sh` to replace the entire git history with a single commit.
- Added `vision.ts` and `vision.spec.ts` for processing images with AI, including metadata extraction and merging.
- Enhanced error handling and logging in vision processing scripts.
2026-04-21 23:17:21 +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/`);
}
}