Skip to content

Commit

Permalink
feat: PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuk1ko committed Jun 9, 2024
1 parent d192093 commit d28d251
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-pwa/client" />
/// <reference types="vite-plugin-comlink/client" />
/// <reference types="unplugin-icons/types/vue3" />
/// <reference types="vite-svg-loader" />
Expand Down
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="msapplication-TileColor" content="#f4f4f5" />
<meta name="theme-color" content="#f4f4f5" />
<meta name="format-detection" content="telephone=no" />
<meta name="description" content="Browsing Unity AssetBundle on the web." />
<meta name="keywords" content="Unity,AssetBundle,AssetStudio" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AS Web</title>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"unplugin-vue-components": "^0.27.0",
"vite": "^5.2.13",
"vite-plugin-comlink": "^5.0.1",
"vite-plugin-pwa": "^0.20.0",
"vite-svg-loader": "^5.1.0",
"vue-tsc": "^2.0.21"
}
Expand Down
16 changes: 0 additions & 16 deletions public/manifest.json

This file was deleted.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './setup/serviceWorker';
// eslint-disable-next-line import/order
import { VxeTableModules } from './setup/vxeTable';
import 'splitpanes/dist/splitpanes.css';
Expand Down
3 changes: 3 additions & 0 deletions src/setup/serviceWorker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { registerSW } from 'virtual:pwa-register';

registerSW({ immediate: true });
29 changes: 29 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,42 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
import { comlink } from 'vite-plugin-comlink';
import { VitePWA } from 'vite-plugin-pwa';
import SvgLoader from 'vite-svg-loader';

const pathSrc = resolve(__dirname, 'src');

// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
build: {
sourcemap: true,
},
plugins: [
VitePWA({
registerType: 'autoUpdate',
workbox: {
maximumFileSizeToCacheInBytes: 4e6,
},
manifest: {
name: 'AS Web',
short_name: 'AS Web',
background_color: '#f4f4f5',
theme_color: '#f4f4f5',
display: 'standalone',
icons: [
{
sizes: '192x192',
src: '/android-chrome-192x192.png',
type: 'image/png',
},
{
sizes: '512x512',
src: '/android-chrome-512x512.png',
type: 'image/png',
},
],
},
}),
comlink(),
Vue(),
SvgLoader(),
Expand Down

0 comments on commit d28d251

Please sign in to comment.