-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.ts
More file actions
61 lines (60 loc) · 1.5 KB
/
vite.config.ts
File metadata and controls
61 lines (60 loc) · 1.5 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
58
59
60
61
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
// https://vitejs.dev/config/
export default defineConfig({
// Base path for GitHub Pages deployment
base: '/alphago-zero-tictactoe-js/',
plugins: [
react(),
nodePolyfills({
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
globals: {
Buffer: true,
global: true,
process: true
}
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'buffer': 'buffer',
},
},
define: {
// This ensures compatibility with react-scripts
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.PUBLIC_URL': JSON.stringify(process.env.PUBLIC_URL || ''),
// This helps with libraries that assume Node.js globals exist
global: 'window',
},
server: {
port: 3000,
},
build: {
outDir: 'dist',
rollupOptions: {
// Externalize dependencies that can't be bundled correctly
external: ['@d4c/numjs'],
output: {
globals: {
'@d4c/numjs': 'numjs',
},
paths: {
'@d4c/numjs': 'https://cdn.jsdelivr.net/npm/@d4c/numjs/build/module/numjs.min.js',
},
},
},
},
optimizeDeps: {
esbuildOptions: {
// Enable node globals for libraries that depend on them
define: {
global: 'globalThis',
},
},
},
});