-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathvite.config.js
More file actions
94 lines (92 loc) · 2.2 KB
/
vite.config.js
File metadata and controls
94 lines (92 loc) · 2.2 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import legacy from '@vitejs/plugin-legacy';
import { execSync } from 'child_process';
function getCommitHash() {
try {
return execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
} catch (error) {
return 'unknown';
}
}
export default defineConfig({
plugins: [
preact({
devToolsEnabled: true,
}),
legacy({
targets: ['defaults', 'not IE 11'],
}),
],
root: 'src',
publicDir: '../static',
build: {
outDir: '../dist',
emptyOutDir: true,
assetsDir: 'assets',
},
define: {
__COMMITHASH__: JSON.stringify(getCommitHash()),
},
resolve: {
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
esbuild: {
loader: 'jsx',
include: [
// src
/src\/.*\.[jt]sx?$/,
// node_modules
/node_modules\/.*\.jsx$/,
],
},
optimizeDeps: {
esbuildOptions: {
loader: {
'.js': 'jsx',
},
},
},
css: {
postcss: './postcss.config.js',
},
server: {
host: true,
port: 3000,
proxy: {
'/create-share': {
target: 'http://127.0.0.1:5002',
changeOrigin: true,
rewrite: (path) => `/staging-zenuml-27954/us-central1/create_share`
},
'/get-shared-item': {
target: 'http://127.0.0.1:5002/staging-zenuml-27954/us-central1',
changeOrigin: true,
rewrite: (path) => path.replace('/get-shared-item', '/get_shared_item')
},
'/sync-diagram': {
target: 'http://127.0.0.1:5002',
changeOrigin: true,
rewrite: (path) => `/staging-zenuml-27954/us-central1/sync_diagram`
},
'/authenticate': {
target: 'http://127.0.0.1:5002',
changeOrigin: true,
rewrite: (path) => `/staging-zenuml-27954/us-central1/authenticate`
},
'/track': {
target: 'http://127.0.0.1:5002',
changeOrigin: true,
rewrite: (path) => `/staging-zenuml-27954/us-central1/track`
},
'/info': {
target: 'http://127.0.0.1:5002',
changeOrigin: true,
rewrite: (path) => `/staging-zenuml-27954/us-central1/info`
},
}
},
});