-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
115 lines (113 loc) · 3.29 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
import { defineConfig, loadEnv } from "vite";
import { svelte, vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import { VitePWA } from "vite-plugin-pwa";
import path from "path";
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = Object.assign(process.env, loadEnv(mode, process.cwd(), ""));
return defineConfig({
base: process.env.VITE_BASE_URL,
optimizeDeps: {
exclude: ["@ffmpeg/ffmpeg", "@ffmpeg/util"],
},
plugins: [
svelte({
preprocess: [vitePreprocess()],
}),
{
name: "configure-response-headers",
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
next();
});
},
},
{
name: "resolve-package-version",
config: (_, env) => {
if (env) {
const key = "import.meta.env.PACKAGE_VERSION";
const val = JSON.stringify(process.env.npm_package_version);
return { define: { [key]: val } };
}
},
},
VitePWA({
registerType: "prompt",
strategies: "generateSW",
devOptions: {
enabled: true,
type: "module",
},
workbox: {
globPatterns: ["**/*.{js,css,html,ico,woff2}"],
globIgnores: ["**/lib/ffmpeg/**"],
maximumFileSizeToCacheInBytes: 30 * 1024 * 1024,
runtimeCaching: [
{
urlPattern: /(\.*\/)?lib\/ffmpeg\/.*$/,
handler: "CacheFirst",
options: {
cacheName: `wo-ffmpeg-${process.env.VITE_FFMPEG_VERSION}`,
},
},
],
},
manifest: {
name: "Video File Converter",
short_name: "Video Converter",
description: "Badge convert your video files.",
start_url: "./index.html",
display: "standalone",
icons: [
{
src:
process.env.VITE_BASE_URL + "icons/android-chrome-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src:
process.env.VITE_BASE_URL + "icons/android-chrome-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
theme_color: "#4f46e5",
background_color: "#3f3f46",
screenshots: [
{
src: "screenshot.jpg",
sizes: "420x910",
type: "image/jpeg",
label: "Homescreen of Video File Converter",
},
{
src: "screenshot-wide.jpg",
sizes: "960x808",
type: "image/jpeg",
form_factor: "wide",
label: "Homescreen of Video File Converter",
},
],
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
esbuild: {
drop: ["console", "debugger"],
},
preview: {
headers: {
"Cross-Origin-Embedder-Policy": "require-corp",
"Cross-Origin-Opener-Policy": "same-origin",
},
},
});
};