1
0
Fork 0
mirror of https://github.com/cheeaun/phanpy.git synced 2025-05-11 01:15:47 +03:00

It's time for MVP PWA/ServiceWorker

- Not 100% offline yet, very minimal caching
- Fix logo a little
This commit is contained in:
Lim Chee Aun 2022-12-19 14:51:56 +08:00
parent 40b2f5b65c
commit ee360403fd
12 changed files with 6018 additions and 64 deletions

View file

@ -2,16 +2,53 @@ import preact from '@preact/preset-vite';
import { execSync } from 'child_process';
import { resolve } from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
const { VITE_CLIENT_NAME: CLIENT_NAME, NODE_ENV } = process.env;
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
// https://vitejs.dev/config/
export default defineConfig({
mode: NODE_ENV,
define: {
__BUILD_TIME__: JSON.stringify(Date.now()),
__COMMIT_HASH__: JSON.stringify(commitHash),
},
plugins: [preact(), splitVendorChunkPlugin()],
plugins: [
preact(),
splitVendorChunkPlugin(),
VitePWA({
manifest: {
name: CLIENT_NAME,
short_name: CLIENT_NAME,
description: 'Minimalistic opinionated Mastodon web client',
theme_color: '#ffffff',
icons: [
{
src: 'logo-192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'logo-512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
strategies: 'injectManifest',
injectRegister: 'inline',
injectManifest: {
// Prevent "Unable to find a place to inject the manifest" error
injectionPoint: undefined,
},
devOptions: {
enabled: NODE_ENV === 'development',
type: 'module',
},
}),
],
build: {
sourcemap: true,
rollupOptions: {