-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
93 lines (90 loc) · 2.4 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
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
import { webUpdateNotice } from '@plugin-web-update-notification/vite';
import legacy from '@vitejs/plugin-legacy';
import react from '@vitejs/plugin-react';
import { Buffer } from 'buffer';
import { defineConfig } from 'vite';
import bundlesize from 'vite-plugin-bundlesize';
import { ViteMinifyPlugin } from 'vite-plugin-minify';
import { VitePWA } from 'vite-plugin-pwa';
import { robots } from 'vite-plugin-robots';
import tsconfigPaths from 'vite-tsconfig-paths';
const base64Encode = (plaintext: string): string => {
return Buffer.from(plaintext).toString('base64');
};
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
bundlesize({
limits: [
{
name: '**/*.js',
limit: 250_000, // 250.0KB
},
],
}),
tsconfigPaths(),
ViteMinifyPlugin({}),
legacy({
targets: ['defaults'],
}),
robots(),
webUpdateNotice({
logVersion: true,
versionType: 'build_timestamp',
hiddenDefaultNotification: true,
}),
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
manifest: {
name: 'Frontend App Test',
short_name: 'Frontend',
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
},
workbox: {
maximumFileSizeToCacheInBytes: 5_000_000,
},
}),
],
server: {
proxy: {
'/rest': {
target: 'http://localhost:4010',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/rest/, ''),
secure: false,
},
'/misc/tp': {
target: 'http://localhost:4318',
rewrite: (path) => path.replace('/misc/tp', '/v1/traces'),
},
},
},
build: {
sourcemap: true,
chunkSizeWarningLimit: 1_600, // 1.6KB
rollupOptions: {
output: {
manualChunks: (id) => {
if (/project-env-variables.ts/.test(id)) {
return 'project-env-variables';
}
if (id.includes('node_modules')) {
const cleanName = id
.toString()
.split('node_modules/')[1]
.split('/')[0]
.toString();
return cleanName + '-' + base64Encode(cleanName);
}
},
chunkFileNames: 'assets/chunks/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash][extname]',
},
},
},
});