diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest deleted file mode 100644 index 818e94f18..000000000 --- a/public/manifest.webmanifest +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "micro:bit Python Editor", - "short_name": "micro:bit Python Editor", - "start_url": "/", - "display": "standalone", - "background_color": "#ffffff", - "lang": "en", - "scope": "/", - "description": "A Python Editor for the BBC micro:bit, built by the Micro:bit Educational Foundation and the global Python Community.", - "theme_color": "#6c4bc1", - "icons": [ - { "src": "/logo512.png", "sizes": "512x512", "type": "image/png" }, - { "src": "/logo192.png", "sizes": "192x192", "type": "image/png" } - ] -} diff --git a/vite.config.ts b/vite.config.ts index 1e19e589b..c3f95344d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -29,6 +29,27 @@ const viteEjsPlugin = ({ data }: { data: ejs.Data }): Plugin => ({ }, }); +// Removes webmanifest link tag from output index.html file. +// We add this tag if PWA features are enabled via a feature flag. +const viteRemoveManifestPlugin = (): Plugin => ({ + name: "Manifest", + enforce: "post", + transformIndexHtml: { + order: "post", + handler: ( + html: string, + _ctx: IndexHtmlTransformContext + ): IndexHtmlTransformResult => { + return html.replace( + ``, + "" + ); + }, + }, +}); + export default defineConfig(({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; const unitTest: UserConfig["test"] = { @@ -126,11 +147,27 @@ export default defineConfig(({ mode }) => { }, ], }, - // See manifest.webmanifest in public/ - // It has been split out so we can inject it if enabled - // via feature flag. - manifest: false, + manifest: { + name: "micro:bit Python Editor", + short_name: "micro:bit Python Editor", + description: + "A Python Editor for the BBC micro:bit, built by the Micro:bit Educational Foundation and the global Python Community.", + theme_color: "#6c4bc1", + icons: [ + { + src: `${process.env.BASE_URL ?? "/"}logo512.png`, + sizes: "512x512", + type: "image/png", + }, + { + src: `${process.env.BASE_URL ?? "/"}logo192.png`, + sizes: "192x192", + type: "image/png", + }, + ], + }, }), + viteRemoveManifestPlugin(), ], test: unitTest, resolve: {