-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvite.config.js
74 lines (72 loc) · 1.88 KB
/
vite.config.js
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
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import viteCompression from "vite-plugin-compression";
const vitePWAconfiguration = {
devOptions: {
enabled: false,
suppressWarnings: true,
},
workbox: {
sourcemap: false,
cleanupOutdatedCaches: false,
maximumFileSizeToCacheInBytes: 10000000,
globPatterns: [
"**/*.{js,js.gz,css,html,gif,png,json,woff,woff2,json,ogg,wav,mp3,ico,png,svg}",
"favicon/*.{js,js.gz,css,html,gif,png,json,woff,woff2,json,ogg,wav,mp3,ico,png,svg}",
],
runtimeCaching: [
{
urlPattern: ({ url }) =>
[
/^https:\/\/raw\.githubusercontent\.com\/.*/i,
/^https:\/\/shabda\.ndre\.gr\/.*/i,
].some((regex) => regex.test(url)),
handler: "CacheFirst",
options: {
cacheName: "external-samples",
expiration: {
maxEntries: 5000,
maxAgeSeconds: 60 * 60 * 24 * 30, // <== 14 days
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
manifest: false,
registerType: "autoUpdate",
injectRegister: "script-defer",
};
export default defineConfig(({ command, mode, ssrBuild }) => {
if (command === "serve") {
return {
plugins: [viteCompression(), VitePWA(vitePWAconfiguration)],
assetsInclude: ["**/*.md"],
server: {
port: 8000,
strictPort: true,
},
build: {
outDir: "dist",
emptyOutDir: true,
cssCodeSplit: true,
cssMinify: true,
minify: true,
}
};
} else {
return {
plugins: [viteCompression(), VitePWA(vitePWAconfiguration)],
chunkSizeWarningLimit: 1600 * 2,
build: {
outDir: "dist",
emptyOutDir: true,
cssCodeSplit: true,
cssMinify: true,
minify: true,
},
};
}
});