forked from massalabs/gossip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
127 lines (122 loc) · 3.55 KB
/
Copy pathvite.config.ts
File metadata and controls
127 lines (122 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { VitePWA } from 'vite-plugin-pwa';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import mkcert from 'vite-plugin-mkcert';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
mkcert(), // ← Enables HTTPS locally
nodePolyfills({
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
ViteImageOptimizer({
// SVG optimization with SVGO
svg: {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
// Keep viewBox for responsive SVGs (important for your logo)
removeViewBox: false,
// Remove width/height attributes for better scalability
removeDimensions: true,
// Keep important attributes
removeUselessStrokeAndFill: false,
// Optimize paths but keep them readable
convertPathData: {
floatPrecision: 2,
},
},
},
},
// Sort attributes for better compression
'sortAttrs',
],
},
// Process images from public directory and assets
test: /\.(svg|png|jpg|jpeg|webp)$/,
// Include files from both public and src directories
include: ['**/*.svg', '**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.webp'],
// Exclude already optimized files
exclude: ['**/*.min.*'],
// Enable verbose logging
logStats: true,
}),
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'sw.ts',
registerType: 'prompt',
injectRegister: false,
pwaAssets: {
disabled: false,
config: true,
},
manifest: {
name: 'Gossip',
short_name: 'Gossip',
description: 'Private messaging app',
theme_color: '#0d9488',
background_color: '#f8f9fa',
display: 'standalone',
orientation: 'portrait',
scope: '/',
start_url: '/',
icons: [
{
src: '/favicon/apple-touch-icon.png',
sizes: '180x180',
type: 'image/png',
purpose: 'any',
},
{
src: '/favicon/web-app-manifest-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any',
},
{
src: '/favicon/web-app-manifest-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
{
src: '/favicon/favicon-96x96.png',
sizes: '96x96',
type: 'image/png',
purpose: 'any',
},
],
categories: ['social', 'communication'],
},
injectManifest: {
globPatterns: ['**/*.{js,css,html,svg,png,ico,wasm}'],
maximumFileSizeToCacheInBytes: 3 * 1024 * 1024, // 3MB (increased from default 2MB for crypto polyfills)
},
devOptions: {
enabled: true, // Enable service workers in dev mode for testing
navigateFallback: 'index.html',
suppressWarnings: true,
type: 'module',
},
}),
],
assetsInclude: ['**/*.wasm'],
server: {
fs: {
allow: ['..'],
},
},
build: {
target: 'esnext',
},
});