-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
39 lines (38 loc) · 1.52 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
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import { visualizer } from "rollup-plugin-visualizer";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
build: {
sourcemap: true,
},
css: {
devSourcemap: true,
},
plugins: [
react(),
// We have already written a service worker unser src/service-worker.ts
// We use VitePWA to build that service worker through Vite's pipeline, and to inject the manifest (via workbox-build's injectManifest mode)
// We could remove the dependency by wiring that up manually, but for now this is ok
VitePWA({
// Just inject self.__WB_MANIFEST
strategies: "injectManifest",
// Do not add a registration handler; we do this manually in index.tsx and serviceWorkerRegistration.ts
injectRegister: null,
// Our custom service worker script is under src/service-worker.ts (instead of /public/service-worker.js)
srcDir: "src",
filename: "service-worker.ts",
// Settings for injecting the manifest for precaching
injectManifest: {
// These URLs are already hashed, so no need to cache-bust them
// NOTE: This is the default; leaving it here for posterity
// dontCacheBustURLsMatching: /[.-][a-f0-9]{8}\./,
// Expand the glob patterns (default js,css,html) to include woff2 font files
globPatterns: ["**/*.{js,css,html,woff2}"],
},
outDir: "dist",
}),
visualizer({ template: "sunburst" }),
],
});