-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
65 lines (63 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
58
59
60
61
62
63
64
65
import process from 'node:process';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
// The following are known larger packages or packages that can be loaded asynchronously.
const individuallyPackages = ['activities', 'github.svg', 'grid.svg'];
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
viteTsconfigPaths(),
svgr({
include: ['**/*.svg'],
svgrOptions: {
exportType: 'named',
namedExport: 'ReactComponent',
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
svgoConfig: {
floatPrecision: 2,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeTitle: false,
removeViewBox: false,
},
},
},
],
},
},
}),
],
base: process.env.PATH_PREFIX || '/',
define: {
"import.meta.env.VERCEL": JSON.stringify(process.env.VERCEL),
},
build: {
manifest: true,
outDir: './dist', // for user easy to use, vercel use default dir -> dist
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.includes('node_modules')) {
return 'vendors';
// If there will be more and more external packages referenced in the future,
// the following approach can be considered.
// const name = id.split('node_modules/')[1].split('/');
// return name[0] == '.pnpm' ? name[1] : name[0];
} else {
for (const item of individuallyPackages) {
if (id.includes(item)) {
return item;
}
}
}
},
},
},
},
});