-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
69 lines (44 loc) · 1.56 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
import {defineConfig, type PluginOption} from "vite";
import {visualizer as pluginBundleVisualizer} from "rollup-plugin-visualizer";
import {SvelteKitPWA as pluginPWA} from "@vite-pwa/sveltekit";
import {sveltekit as pluginSvelteKit} from "@sveltejs/kit/vite";
import pluginUnpluginIcons from "unplugin-icons/vite";
import {readFileSync} from "node:fs";
import path from "node:path";
export default defineConfig(args => {
const isDebug = false;
return {
plugins: getPlugins(isDebug),
preview: getPreviewOptions(args.isPreview, isDebug)
}
});
function getPlugins(isDebug: boolean) {
const manifestPath = path.join(__dirname, "static/manifest.json");
const pwaManifest = JSON.parse(readFileSync(manifestPath, {encoding: "utf8"}))!;
const plugins: PluginOption[] = [
pluginSvelteKit(),
pluginPWA({...pwaManifest}),
pluginUnpluginIcons({compiler: "svelte"})
];
if(isDebug) {
plugins.push(pluginBundleVisualizer({
emitFile: true,
template: "flamegraph"
}));
}
return plugins;
}
function getPreviewOptions(isPreview: boolean | undefined, isDebug: boolean) {
// don't read files unless we're actually in deployment
if(isDebug || !isPreview) return undefined;
const certDirectory = "C:\\Certbot\\live\\appdev.jessamine.kyschools.us";
const keyFilePath = path.join(certDirectory, "privkey.pem");
const certFilePath = path.join(certDirectory, "fullchain.pem");
return {
https: {
key: readFileSync(keyFilePath),
cert: readFileSync(certFilePath),
},
proxy: {} // this is needed for some ungodly reason but it fixes my headaches
};
}