forked from inkandswitch/tiny-essay-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
54 lines (53 loc) · 1.83 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
// vite.config.ts
import { defineConfig } from "vite";
import path from "path";
import react from "@vitejs/plugin-react";
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
export default defineConfig({
base: "./",
plugins: [topLevelAwait(), react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
optimizeDeps: {
// This is necessary because otherwise `vite dev` includes two separate
// versions of the JS wrapper. This causes problems because the JS
// wrapper has a module level variable to track JS side heap
// allocations, and initializing this twice causes horrible breakage
exclude: [
"@automerge/automerge-wasm",
"@automerge/automerge-wasm/bundler/bindgen_bg.wasm",
"@syntect/wasm",
],
},
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, "index.html"),
"service-worker": path.resolve(__dirname, "service-worker.js"),
},
output: {
// We put index.css in dist instead of dist/assets so that we can link to fonts
// using relative URLs like "./assets/font.woff2", which is the correct form
// for deployment to trailrunner.
assetFileNames: (assetInfo) => {
if (assetInfo.name === "index.css") {
return "[name][extname]";
}
// For all other assets, keep the default behavior
return "assets/[name]-[hash][extname]";
},
entryFileNames: (chunkInfo) => {
// Specify output location for service-worker.js
if (chunkInfo.name === "service-worker") {
return "[name].js"; // This will place service-worker.js directly under dist
}
return "assets/[name]-[hash].js"; // Default behavior for other entries
},
},
},
},
});