-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
40 lines (37 loc) · 969 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
38
39
40
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path';
import * as fs from 'fs';
const mediapipe_broken_files = [
{ names: ['Hands', 'HAND_CONNECTIONS'], path: 'hands.js' },
{ names: ['Camera'], path: 'camera_utils.js' },
{ names: ['drawConnectors', 'drawLandmarks'], path: 'drawing_utils.js' },
]
function mediapipe_workaround() {
return {
name: 'mediapipe_workaround',
load(id: string) {
for (const file of mediapipe_broken_files) {
if (path.basename(id) === file.path) {
let code = fs.readFileSync(id, 'utf-8');
for (const name of file.names) {
code += `exports.${name} = ${name};`;
}
return {code};
}
}
return null;
},
};
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
build: {
rollupOptions: {
plugins: [
mediapipe_workaround(),
]
}
}
})