diff --git a/ts/controllers/controller.builtin.ts b/ts/controllers/controller.builtin.ts index aeb22a2..143761f 100644 --- a/ts/controllers/controller.builtin.ts +++ b/ts/controllers/controller.builtin.ts @@ -203,4 +203,25 @@ export class BuiltInRoutesController { return new Response('SW-Dash bundle not found', { status: 404 }); } } + + @plugins.smartserve.Get('/serviceworker.bundle.js') + async getServiceWorkerBundle(): Promise { + try { + const bundleContent = (await plugins.fsInstance + .file(paths.serviceworkerBundlePath) + .encoding('utf8') + .read()) as string; + + return new Response(bundleContent, { + status: 200, + headers: { + 'Content-Type': 'text/javascript', + 'Cache-Control': 'no-cache', + }, + }); + } catch (error) { + console.error('Failed to serve serviceworker bundle:', error); + return new Response('ServiceWorker bundle not found', { status: 404 }); + } + } } diff --git a/ts/paths.ts b/ts/paths.ts index ecf8acd..808037f 100644 --- a/ts/paths.ts +++ b/ts/paths.ts @@ -9,6 +9,7 @@ export const injectBundleDir = plugins.path.join(packageDir, './dist_ts_web_inje export const injectBundlePath = plugins.path.join(injectBundleDir, './bundle.js'); export const serviceworkerBundleDir = plugins.path.join(packageDir, './dist_ts_web_serviceworker'); +export const serviceworkerBundlePath = plugins.path.join(serviceworkerBundleDir, './serviceworker.bundle.js'); export const swdashBundleDir = plugins.path.join(packageDir, './dist_ts_swdash'); export const swdashBundlePath = plugins.path.join(swdashBundleDir, './bundle.js'); \ No newline at end of file