-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
57 lines (53 loc) · 1.86 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
/// <reference types="vitest" />
import basicSsl from '@vitejs/plugin-basic-ssl';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { defineConfig } from 'vite';
// This enables cross-origin isolation for the app.
// See https://web.dev/why-coop-coep/
// We do this because we want to use the new API for memory measurement.
const crossOriginIsolation = () => ({
name: 'configure-server',
configureServer(server) {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy-Report-Only', 'same-origin');
res.setHeader('Cross-Origin-Embedder-Policy-Report-Only', 'require-corp');
next();
});
},
});
// https://vitejs.dev/config/
export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
threads: false, // see https://github.com/vitest-dev/vitest/issues/740
deps: {
inline: ['opentype.js'],
},
setupFiles: [
'./src/test/setupFiles/setupGlobals.ts',
'./src/test/setupFiles/setupAndCleanupMocks.ts',
],
},
base: '/threejs-tests', // GH project pages - this is the repo name
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
// resolve three-forcegraph as a module, not a file
mainFields: ['module'],
},
// TODO: We have to make sure that payments do not get affected by this. (Cross-Origin Isolation)
plugins: [react(), crossOriginIsolation(), basicSsl()],
// This project currently uses a forked version of ThreeJS (dev branch + unmerged PRs), to test & debug locally:
// - clone https://github.com/rebeckerspecialties/three.js
// - install the local package in this project (`npm i <path_cloned_threejs>`)
// - enable the flag below
// Enable this to test ThreeJS locally.
optimizeDeps: {
include: ['three'],
},
});