-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
62 lines (61 loc) · 1.46 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
import path from 'path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import fs from "fs"
import { remoteDisplayServer } from './src/vitePlugins/remoteDisplayServer'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig(({ command }) => {
if (command === 'serve') {
return {
root: 'examples',
plugins: [
react(),
nodePolyfills(),
remoteDisplayServer(),
],
resolve: {
alias: {
'three-fiber-webxr-toolbox': path.resolve(process.cwd(), 'src')
}
},
envDir: process.cwd(),
server: {
host: '0.0.0.0',
port: 3001,
https: {
key: fs.readFileSync("./localhost-key.pem"),
cert: fs.readFileSync("./localhost.pem"),
},
}
}
} else {
return {
optimizeDeps: {
exclude: [
'@react-three/fiber',
'@react-three/xr',
'react',
'react-dom',
'three',
]
},
build: {
minify: false,
sourcemap: true,
target: 'es2018',
lib: {
formats: ['es', 'cjs'],
entry: 'src/index.tsx',
fileName: '[name]'
},
rollupOptions: {
external: (id) => !id.startsWith('.') && !path.isAbsolute(id),
output: {
preserveModules: true,
sourcemapExcludeSources: true
}
}
}
}
}
})