-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
65 lines (61 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
55
56
57
58
59
60
61
62
63
64
65
// import * as child from "child_process";
import * as path from "path";
import autoprefixer from "autoprefixer";
import tailwindcss from "tailwindcss";
import { defineConfig } from "vite";
import { VitePWA, VitePWAOptions } from "vite-plugin-pwa";
import solid from "vite-plugin-solid";
import wasm from "vite-plugin-wasm";
import manifest from "./manifest";
// const commitHash = process.env.VITE_COMMIT_HASH ?? "";
// child.execSync("git rev-parse --short HEAD").toString().trim()
const pwaOptions: Partial<VitePWAOptions> = {
base: "/",
registerType: "prompt",
devOptions: {
enabled: false,
},
workbox: {
navigateFallback: "/index.html",
globPatterns: ["**/*.{js,css,html,svg,png,gif,wasm}"],
// mutiny_wasm is 10mb, so we'll do 25mb to be safe
maximumFileSizeToCacheInBytes: 25 * 1024 * 1024,
},
includeAssets: ["favicon.ico", "robots.txt"],
manifest: manifest,
};
export default defineConfig({
build: {
target: "esnext",
outDir: "dist/public",
emptyOutDir: true,
},
server: {
port: 3088,
fs: {
// Allow serving files from one level up (so that if mutiny-node is a sibling folder we can use it locally)
allow: [".."],
},
},
plugins: [wasm(), solid(), VitePWA(pwaOptions)],
// define: {
// "import.meta.env.__COMMIT_HASH__": JSON.stringify(commitHash),
// "import.meta.env.__RELEASE_VERSION__": JSON.stringify(
// process.env.npm_package_version,
// ),
// },
resolve: {
alias: [{ find: "~", replacement: path.resolve(__dirname, "./src") }],
},
optimizeDeps: {
// Don't want vite to bundle these late during dev causing reload
include: [],
// This is necessary because otherwise `vite dev` can't find the wasm
exclude: ["@benthecarman/note-duel"],
},
css: {
postcss: {
plugins: [autoprefixer(), tailwindcss()],
},
},
});