-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
98 lines (94 loc) · 2.61 KB
/
vite.config.ts
File metadata and controls
98 lines (94 loc) · 2.61 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
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { defineConfig, splitVendorChunkPlugin } from "vite";
import react from "@vitejs/plugin-react-swc";
import eslintPlugin from "vite-plugin-eslint";
import { VitePWA } from "vite-plugin-pwa";
// Automatic dependency splitting
import { dependencies } from "./package.json";
const renderChunks = (deps: Record<string, string>) => {
const chunks = {};
Object.keys(deps).forEach((key) => {
const ignoreList = [
"webtorrent",
"@fontsource/fira-code",
"@fontsource/open-sans",
"material-symbols",
];
if (ignoreList.includes(key)) return;
chunks[key] = [key];
});
return chunks;
};
// Dependency Visualization
//import { visualizer } from "rollup-plugin-visualizer";
//import { type PluginOption } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
eslintPlugin(),
// https://vite-pwa-org.netlify.app/guide/pwa-minimal-requirements.html
// https://developer.mozilla.org/docs/Web/Manifest
// https://web.dev/add-manifest/
VitePWA({
registerType: "autoUpdate",
includeAssets: [
"cocast.svg",
"favicon.ico",
"favicon-16x16.png",
"favicon-32x32.png",
"apple-touch-icon.png",
"mask-icon.svg",
],
manifest: {
name: "CoCast",
short_name: "CoCast",
description:
"CoCast is a free and open-source media casting application that allows you to watch your favorite videos with friends from anywhere in the world!",
theme_color: "#0f0f0f",
background_color: "#0f0f0f",
icons: [
{
src: "pwa-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "pwa-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
},
}),
splitVendorChunkPlugin(),
//visualizer() as PluginOption,
],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./src/setup.ts"],
},
esbuild: {
drop: ["debugger"], // https://esbuild.github.io/api/#drop
pure: ["console.debug"], // https://esbuild.github.io/api/#pure
},
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
...renderChunks(dependencies),
},
},
},
},
server: {
// Needed for changes to picked up when running in WSL on Windows
watch: {
usePolling: true,
},
},
base: "/cocast/", // For GitHub Pages: https://vitejs.dev/guide/static-deploy.html#github-pages
});