-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
37 lines (34 loc) · 943 Bytes
/
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
import glsl from "vite-plugin-glsl";
import { defineConfig, loadEnv } from "vite";
import { readdirSync, lstatSync } from "fs";
import { resolve } from "path";
const env = loadEnv("all", process.cwd());
const SKETCHES_DIR = resolve(__dirname, env.VITE_SKETCHES_DIR!);
function createInput() {
return readdirSync(SKETCHES_DIR)
.filter((sketch) => lstatSync(resolve(SKETCHES_DIR, sketch)).isDirectory())
.reduce(
(acc, sketch) => ({
...acc,
[sketch]: resolve(SKETCHES_DIR, sketch, "index.html"),
}),
{
index: resolve(__dirname, "index.html"),
},
);
}
// https://vitejs.dev/guide/build.html#multi-page-app
export default defineConfig({
plugins: [glsl()],
build: {
rollupOptions: {
input: createInput(),
external: [resolve("template.html"), resolve("sketch.ts")],
},
},
resolve: {
alias: {
shared: resolve(__dirname, "shared"),
},
},
});