Skip to content

Commit

Permalink
migrate to vite-pwa-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Oct 8, 2021
1 parent fbc134c commit 349b5f4
Show file tree
Hide file tree
Showing 8 changed files with 2,118 additions and 59 deletions.
17 changes: 2 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>vizarr</title>
<meta charset="utf-8" />
<meta name="description" content="A minimal, purely client-side program for viewing Zarr-based images." />

<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔬</text></svg>">
<link rel="alternate icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="A minimal, purely client-side program for viewing Zarr-based images." />

<link rel="manifest" href="%PUBLIC_URL%manifest.json">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="application-name" content="vizarr">
<meta name="apple-mobile-web-app-title" content="vizarr">
<meta name="theme-color" content="#000000">
<meta name="msapplication-navbutton-color" content="#000000">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="msapplication-starturl" content=".">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>vizarr</title>
</head>
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script type="module" src="/src/index.tsx"></script>
<script type="module">
// Check if service worker is supported
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register(new URL('sw.js', import.meta.url))
});
}
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap');
html {
Expand Down
2,080 changes: 2,069 additions & 11 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@vitejs/plugin-react": "^1.0.1",
"prettier": "^2.2.0",
"typescript": "^4.4.3",
"vite": "^2.5.10"
"vite": "^2.5.10",
"vite-plugin-pwa": "^0.11.3"
}
}
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { version } from '../package.json';

console.log(`vizarr v${version}: https://github.com/hms-dbmi/vizarr`);

import { registerSW } from 'virtual:pwa-register';
registerSW();

ReactDOM.render(
<ThemeProvider theme={theme}>
<Provider>
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"importsNotUsedAsValues": "error",
"paths": {
"zarr": ["node_modules/zarr"]
}
},
"types": [
"vite-plugin-pwa/client"
]
}
}
39 changes: 38 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
// @ts-check
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';

import { resolve } from 'path';

const manifest = {
name: 'vizarr',
short_name: 'vizarr',
lang: 'en-US',
start_url: '.',
display: 'standalone',
theme_color: '#000000',
icons: [
{
src: 'logo-512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'logo-256.png',
sizes: '256x256',
type: 'image/png',
},
{
src: 'logo-192.png',
sizes: '192x192',
type: 'image/png',
},
],
};

export default defineConfig({
plugins: [react()],
plugins: [
react(),
VitePWA({
includeAssets: ['favicon.svg', 'favicon.ico', 'robots.txt'],
manifest,
workbox: {
globPatterns: ['**/*.{js,json,ico,png,html,txt}'],
},
}),
],
base: process.env.VIZARR_PREFIX || './',
build: {
outDir: 'out',
Expand Down
5 changes: 0 additions & 5 deletions workbox-config.js

This file was deleted.

0 comments on commit 349b5f4

Please sign in to comment.