-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvite.config.js
153 lines (151 loc) · 6.61 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react-swc";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import packageJson from "./package.json";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const isElectron = mode === "electron";
const isDev = mode === "development";
const base = process.env.VITE_BASE || isElectron ? "./" : isDev ? "/" : "/ispeakerreact/";
return {
base: base,
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
return id.toString().split("node_modules/")[1].split("/")[0].toString();
}
},
},
},
manifest: true,
},
plugins: [
react(),
visualizer(),
tailwindcss(),
!isElectron &&
VitePWA({
registerType: "autoUpdate",
manifest: {
name: "iSpeakerReact",
short_name: "iSpeakerReact",
theme_color: "#fdfdf5",
background_color: "#2a303c",
description:
"An English-learning interactive tool written in React, designed to help learners practice speaking and listening.",
lang: "en",
icons: [
{
src: `${base}images/icons/ios/192.png`,
sizes: "192x192",
type: "image/png",
},
{
src: `${base}images/icons/ios/512.png`,
sizes: "512x512",
type: "image/png",
},
],
screenshots: [
{
src: `${base}images/screenshots/screenshot-00.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-01.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-02.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-03.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-04.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-05.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-06.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
{
src: `${base}images/screenshots/screenshot-07.webp`,
sizes: "1920x1080",
type: "image/webp",
form_factor: "wide",
},
],
id: "page.yell0wsuit.ispeakerreact",
dir: "auto",
orientation: "any",
categories: ["education"],
prefer_related_applications: false,
},
workbox: {
// Exclude index.html from caching
// globIgnores: ["**/index.html"],
runtimeCaching: [
{
// Files that need caching permanently
urlPattern: /\.(?:woff2|ttf|jpg|jpeg|webp|svg|ico|png)$/,
handler: "CacheFirst",
options: {
cacheName: "permanent-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
},
},
{
// Cache other assets dynamically with versioning
urlPattern: /\.(?:js|css|json|html)$/,
handler: "CacheFirst",
options: {
cacheName: `dynamic-cache-v${packageJson.version}`,
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
},
},
},
],
},
}),
],
define: {
__APP_VERSION__: JSON.stringify(packageJson.version), // Inject version
},
server: {
fs: {
// Allow serving files from one level up to the project root
allow: [".."],
},
},
};
});