-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvite.config.js
More file actions
57 lines (54 loc) · 1.3 KB
/
Copy pathvite.config.js
File metadata and controls
57 lines (54 loc) · 1.3 KB
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
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import glsl from 'vite-plugin-glsl';
import handlebars from 'vite-plugin-handlebars';
import { pageData } from './src/consts/';
const __dirname = dirname(fileURLToPath(import.meta.url));
// https://vitejs.dev/config/
export default defineConfig({
root: resolve(__dirname, 'src'),
base: '/threejs-experiments/',
plugins: [
glsl(),
handlebars({
partialDirectory: resolve(__dirname, 'src/templates'),
context(pagePath) {
const page = pageData.find((page) => page.path === pagePath);
if (pagePath === '/index.html') {
return {
...page,
sketches: pageData.filter((page) => page.path !== '/index.html'),
};
}
return page;
},
helpers: {
eq: (a, b) => a === b,
},
}),
],
resolve: {
alias: {
'~': resolve(__dirname, 'src'),
},
},
server: {
host: true,
port: 3000,
},
build: {
emptyOutDir: true,
rollupOptions: {
input: Object.fromEntries(
pageData.map((page) => [
page.key,
resolve(__dirname, `src${page.path}`),
]),
),
output: {
dir: resolve(__dirname, 'dist'),
},
},
},
});