init
This commit is contained in:
commit
017bf6e067
115 changed files with 19650 additions and 0 deletions
17
scripts/copy-sw.js
Normal file
17
scripts/copy-sw.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// 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/`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue