From 78967fca4cacbc247fa6fb62d64b2d6825a10804 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Feb 2018 14:15:23 +0100 Subject: Register service worker --- server/controllers/client.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'server/controllers/client.ts') diff --git a/server/controllers/client.ts b/server/controllers/client.ts index f5124c55b..2fcca6f76 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -11,8 +11,6 @@ const clientsRouter = express.Router() const distPath = join(root(), 'client', 'dist') const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images') -const manifestPath = join(root(), 'client', 'dist', 'manifest.json') -const serviceWorkerPath = join(root(), 'client', 'dist', 'ngsw-worker.js') const embedPath = join(distPath, 'standalone', 'videos', 'embed.html') const indexPath = join(distPath, 'index.html') @@ -27,8 +25,17 @@ clientsRouter.use('/videos/embed', (req: express.Request, res: express.Response, }) // Static HTML/CSS/JS client files -clientsRouter.use('/manifest.json', express.static(manifestPath, { maxAge: STATIC_MAX_AGE })) -clientsRouter.use('/ngsw-worker.js', express.static(serviceWorkerPath, { maxAge: STATIC_MAX_AGE })) + +const staticClientFiles = [ + 'manifest.json', + 'ngsw-worker.js', + 'ngsw.json' +] +for (const staticClientFile of staticClientFiles) { + const path = join(root(), 'client', 'dist', staticClientFile) + clientsRouter.use('/' + staticClientFile, express.static(path, { maxAge: STATIC_MAX_AGE })) +} + clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE })) clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE })) -- cgit v1.2.3