-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- update pwa setup to work with public_path external cdn
- Loading branch information
1 parent
af64430
commit ee414a0
Showing
8 changed files
with
54 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './render' | ||
export * from './health' | ||
export * from './version' | ||
export * from './pwa' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Request, Response } from 'express' | ||
import { basename, publicPath } from 'src/common' | ||
|
||
export const getManifest = (_: Request, res: Response) => { | ||
res.json({ | ||
short_name: 'SSR app', | ||
name: 'SSR app', | ||
start_url: basename, | ||
display: 'standalone', | ||
theme_color: '#efefef', | ||
background_color: '#f2f4f6', | ||
icons: [ | ||
{ | ||
src: publicPath('icons/192.png'), | ||
sizes: '192x192' | ||
}, | ||
{ | ||
src: publicPath('icons/512.png'), | ||
sizes: '512x512' | ||
}, | ||
{ | ||
src: publicPath('icons/maskable.png'), | ||
sizes: '150x150', | ||
type: 'image/svg+xml', | ||
purpose: 'any' | ||
}, | ||
{ | ||
src: publicPath('icons/maskable.png'), | ||
type: 'image/svg+xml', | ||
purpose: 'maskable' | ||
} | ||
] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { type Router, static as staticRoute } from 'express' | ||
import { resolve } from 'path' | ||
|
||
import { basename, basePath } from 'src/common' | ||
import { getManifest } from '../controller' | ||
import { pwa } from '../middleware' | ||
|
||
export const pwaRoutes = (router: Router) => { | ||
if (IS_DEV) return | ||
|
||
router.get(basePath('/manifest.json'), getManifest) | ||
router.use(basename, pwa, staticRoute(resolve(__dirname, '../client/pwa'), { redirect: false })) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
import { resolve } from 'path' | ||
import { Router, static as staticRoute } from 'express' | ||
import { pwa } from 'server/middleware' | ||
import { basename } from 'src/common' | ||
|
||
export function staticRoutes(router: Router) { | ||
const distClient = resolve(__dirname, '../client') | ||
router.use(staticRoute(IS_DEV ? 'assets' : distClient)) | ||
|
||
if (IS_PROD) { | ||
router.use(basename, pwa, staticRoute(resolve(distClient, 'pwa'), { redirect: false })) | ||
} | ||
router.use(staticRoute(IS_DEV ? 'assets' : resolve(__dirname, '../client'))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters