forked from isaac-mason/sketches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
75 lines (71 loc) · 2.19 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
66
67
68
69
70
71
72
73
74
75
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { imagetools } from 'vite-imagetools'
import { createHtmlPlugin } from 'vite-plugin-html'
import basicSsl from '@vitejs/plugin-basic-ssl'
// https://vitejs.dev/config/
export default defineConfig(() => {
const gtagId = process.env.VITE_GTAG_ID
const analyticsScript = gtagId
? `
<script async src="https://www.googletagmanager.com/gtag/js?id=${gtagId}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '${gtagId}');
</script>
`
: `
<script>
window.dataLayer = [];
function gtag() { dataLayer.push(arguments); }
</script>
`
return {
plugins: [
react({
babel: {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
},
}),
createHtmlPlugin({
minify: true,
inject: {
data: {
analyticsScript,
},
},
}),
imagetools(),
{
name: 'configure-server',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
// required for SharedArrayBuffer
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
next()
})
},
},
// for easy local development of xr sketches
basicSsl(),
],
optimizeDeps: {
exclude: [
// these packages do not play nicely with vite pre-bundling
'recast-navigation',
'jolt-physics',
],
},
build: {
target: 'esnext',
},
}
})