-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.js
More file actions
57 lines (55 loc) · 1.78 KB
/
Copy pathvite.config.js
File metadata and controls
57 lines (55 loc) · 1.78 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
import { loadEnv, defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
base: env.ASSETS_BASE,
plugins: [react()],
resolve: {
extensions: ['.js', '.jsx', '.json']
},
esbuild: {
loader: "jsx",
include: /src\/.*\.jsx?$/,
exclude: []
},
optimizeDeps: {
esbuildOptions: {
loader: {
'.js': 'jsx'
}
}
},
build: {
outDir: 'build',
sourcemap: true,
assetsDir: 'assets',
chunkSizeWarningLimit: 2500,
rollupOptions: {
output: {
assetFileNames: 'assets/[hash:20][extname]',
chunkFileNames: 'assets/[hash:20].js',
entryFileNames: 'assets/[hash:20].js',
hashCharacters: 'hex',
}
}
},
server: {
// https://github.com/vitejs/vite/discussions/13280
proxy: {
'/__vite_dev_proxy__': {
changeOrigin: true,
configure(_, options) {
options.rewrite = path => {
const proxyUrl = new URL(path, 'file:'),
url = new URL(proxyUrl.searchParams.get('url'));
// Since JS is single threaded, so it won't cause problem
options.target = url.origin;
return url.pathname + url.search;
};
},
},
}
},
};
});