-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
125 lines (123 loc) · 3.63 KB
/
vite.config.ts
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
import { fileURLToPath, URL } from 'url';
import { viteI18nPlugin } from '@dvcol/vite-plugin-i18n';
import suidPlugin from '@suid/vite-plugin';
import devtoolsPlugin from 'solid-devtools/vite';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import solidPlugin from 'vite-plugin-solid';
import solidSVGPlugin from 'vite-plugin-solid-svg';
export default defineConfig({
plugins: [
viteI18nPlugin({
path: 'src/i18n',
out: true,
}),
devtoolsPlugin({
autoname: true,
locator: {
targetIDE: 'webstorm',
componentLocation: true,
jsxLocation: true,
},
}),
suidPlugin(),
solidPlugin(),
solidSVGPlugin({
defaultAsComponent: true,
}),
VitePWA({
registerType: 'prompt',
includeAssets: ['**/favicon.ico', '**/icon.svg', '**/icon*.png'],
manifest: {
name: 'Dinh-Van Colomban',
short_name: 'Dinh-Van',
description: "Web app for Dinh-Van's projects",
theme_color: '#2a2b30',
background_color: '#1d1e21',
display: 'standalone',
icons: [
{
src: 'assets/png/192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'assets/png/512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'assets/png/512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
devOptions: {
enabled: !!process.env.SERVICE_WOKER,
},
workbox: {
sourcemap: !!process.env.SERVICE_WOKER,
importScripts: [process.env.SERVICE_WOKER ? 'src/sw/worker.ts' : 'entry/worker.entry.js'],
globPatterns: ['**/*.{js,css,html,ico,png,svg,json,mp4}'],
globIgnores: ['entry/worker.entry.js'],
navigateFallbackDenylist: [
/[^#]*\/redirect-to([/?].*|#\/?|$)/,
/[^#]*\/about-me([/?].*|#\/?|$)/,
/[^#]*\/synology-download([/?].*|#\/?|$)/,
/[^#]*\/trakt-extension([/?].*|#\/?|$)/,
/[^#]*\/reddit-extension([/?].*|#\/?|$)/,
/[^#]*\/image-viewer([/?].*|#\/?|$)/,
/[^#]*\/syno-trakt([/?].*|#\/?|$)/,
/[^#]*\/neo-svelte([/?].*|#\/?|$)/,
/[^#]*\/svelte-simple-router([/?].*|#\/?|$)/,
/^\/assets\/.*/,
/[?&]no-sw=true/,
],
},
}),
],
server: {
port: 3000,
host: true,
open: true,
},
preview: {
port: 3002,
host: true,
open: true,
},
build: {
target: 'esnext',
outDir: 'dist',
chunkSizeWarningLimit: 1500,
rollupOptions: {
input: {
shell: 'index.html',
worker: 'src/sw/worker.ts',
lottie: 'src/apps/lottie/entry.ts',
'about-me': 'src/apps/about-me/entry.ts',
synology: 'src/apps/synology-extension/entry.ts',
},
output: {
manualChunks: {},
chunkFileNames: 'chunks/[name].chunk.[hash].js',
entryFileNames: entry => `entry/[name].entry${entry.name !== 'worker' ? '.[hash]' : ''}.js`,
assetFileNames: asset => {
const format = '[name][extname]';
if (asset.name?.endsWith('.png')) return `assets/png/${format}`;
if (asset.name?.endsWith('.gif')) return `assets/gif/${format}`;
if (asset.name?.endsWith('.lottie')) return `assets/lottie/${format}`;
if (asset.name?.endsWith('css')) return `styles/${format}`;
return `assets/[name][extname]`;
},
},
},
},
resolve: {
alias: {
'~': fileURLToPath(new URL('./src', import.meta.url)),
},
},
});