Skip to content

Commit

Permalink
refactor: move service-worker-integration to config dir and make the …
Browse files Browse the repository at this point in the history
…build fail if building the service worker fails
  • Loading branch information
decrek committed Jan 10, 2025
1 parent 86164f3 commit 6013ff7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sitemap from '@astrojs/sitemap';
import type { PluginOption } from 'vite';
import { isPreview } from './config/preview';
import pkg from './package.json';
import serviceWorker from './scripts/service-worker-integration.ts';
import serviceWorker from './config/astro/service-worker-integration.ts';

const productionUrl = `https://${ pkg.name }.pages.dev`; // overwrite if you have a custom domain
const localhostPort = 4323; // 4323 is "head" in T9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { APIRoute, AstroIntegration } from 'astro';
import { fileURLToPath } from 'node:url';
import * as esbuild from 'esbuild';

const serviceWorkerSrc = fileURLToPath(new URL('../src/assets/service-worker.ts', import.meta.url));
const serviceWorkerDist = fileURLToPath(new URL('../dist/service-worker.js', import.meta.url));
const serviceWorkerSrc = fileURLToPath(new URL('../../src/assets/service-worker.ts', import.meta.url));
const serviceWorkerDist = fileURLToPath(new URL('../../dist/service-worker.js', import.meta.url));

export default function serviceWorkerIntegration(): AstroIntegration {
return {
Expand Down Expand Up @@ -37,6 +37,7 @@ export default function serviceWorkerIntegration(): AstroIntegration {
} catch (e) {
console.error('Failed to build service worker');
console.error(e);
process.exit(1);
}
},
},
Expand Down

0 comments on commit 6013ff7

Please sign in to comment.