-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
71 lines (68 loc) · 1.78 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
/**
* @file The vite configuration.
*/
import {defineConfig, normalizePath} from "vite";
import {dirname} from "node:path";
import {fileURLToPath} from "node:url";
import {nodePolyfills} from "vite-plugin-node-polyfills";
import process from "node:process";
import {purgeCss} from "vite-plugin-tailwind-purgecss";
import {serviceWorkerName} from "./src/lib/const.js";
import {sveltekit} from "@sveltejs/kit/vite";
import {SvelteKitPWA} from "@vite-pwa/sveltekit";
import topLevelAwait from "vite-plugin-top-level-await";
import {viteStaticCopy} from "vite-plugin-static-copy";
import {webmanifest} from "./src/lib/ServiceWorker/webmanifest.js";
const extensions = [
"js",
"css",
"html",
"ico",
"png",
"svg",
"wasm",
"webmanifest",
"json"
].join(",");
const vipsPath = normalizePath(
dirname(fileURLToPath(import.meta.resolve("wasm-vips")))
);
export default defineConfig({
// For service worker:
define: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"process.env.NODE_ENV":
process.env.NODE_ENV === "production" ? '"production"' : '"development"'
},
plugins: [
sveltekit(),
SvelteKitPWA({
devOptions: {
enabled: true,
type: "module"
},
filename: `${serviceWorkerName}.ts`,
injectManifest: {
globPatterns: [`client/**/*.{${extensions}}`],
// prettier-ignore
maximumFileSizeToCacheInBytes: 8 * (1000 ** 2)
},
injectRegister: undefined,
manifest: webmanifest,
minify: true,
srcDir: "src",
strategies: "injectManifest"
}),
topLevelAwait(),
nodePolyfills(),
viteStaticCopy({
targets: [
{
dest: "vips",
src: `${vipsPath}/vips{{,-es6}{,.worker}.js,*.wasm}`
}
]
}),
purgeCss()
]
});