-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathvite.config.ts
More file actions
134 lines (127 loc) · 4.23 KB
/
Copy pathvite.config.ts
File metadata and controls
134 lines (127 loc) · 4.23 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react'
import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
import path from 'path'
import { visualizer } from "rollup-plugin-visualizer";
import { splitVendorChunkPlugin } from 'vite'
import obfuscator from 'rollup-plugin-obfuscator';
import { resolve } from 'path';
import { readFileSync } from 'fs';
import envCompatible from 'vite-plugin-env-compatible';
const version: string = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8')).version;
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
base: '/daily',
server: {
proxy: {
"/daily/api": {
target: env.AUTOPCR_SERVER_HOST || 'http://localhost:13200',
changeOrigin: true,
},
},
host: env.AUTOPCR_WEBUI_LISTEN || 'localhost'
},
define: {
'APP_VERSION': JSON.stringify(version),
},
plugins: [
react(),
TanStackRouterVite(),
splitVendorChunkPlugin(),
visualizer({
open: true,
}),
envCompatible({
mountedPath: 'process.env',
}),
obfuscator({
global:false,
options: {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
numbersToExpressions: true,
simplify: true,
stringArrayShuffle: true,
splitStrings: true,
splitStringsChunkLength: 10,
rotateUnicodeArray: true,
deadCodeInjection: false,
// deadCodeInjectionThreshold: 0.4,
debugProtection: false,
debugProtectionInterval: 2000,
disableConsoleOutput: true,
domainLock: [],
identifierNamesGenerator: "hexadecimal",
identifiersPrefix: "",
inputFileName: "",
log: true,
renameGlobals: true,
reservedNames: [],
reservedStrings: [],
seed: 0,
selfDefending: true,
sourceMap: false,
sourceMapBaseUrl: "",
sourceMapFileName: "",
sourceMapMode: "separate",
stringArray: true,
stringArrayEncoding: ["base64"],
stringArrayThreshold: 0.75,
target: "browser",
transformObjectKeys: true,
unicodeEscapeSequence: true,
domainLockRedirectUrl: "about:blank",
forceTransformStrings: [],
identifierNamesCache: null,
identifiersDictionary: [],
ignoreImports: true,
optionsPreset: "default",
renameProperties: false,
renamePropertiesMode: "safe",
sourceMapSourcesMode: "sources-content",
stringArrayCallsTransform: true,
stringArrayCallsTransformThreshold: 0.5,
stringArrayIndexesType: ["hexadecimal-number"],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: "variable",
}
})
],
build: {
target: 'es2020',
sourcemap: false,
brotliSize: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('xlsx') || id.includes('file-saver')) return 'xlsx';
if (id.includes('react-icons')) return 'icons';
if (id.includes('@chakra-ui') || id.includes('@emotion') || id.includes('framer-motion')) return 'chakra';
if (id.includes('@tanstack') || id.includes('react-location')) return 'tanstack';
if (id.includes('axios')) return 'utils';
if (id.includes('react') || id.includes('react-dom')) return 'react-vendor';
return 'vendor'
}
}
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@api': path.resolve(__dirname, 'src/api'),
'@components': path.resolve(__dirname, 'src/components'),
'@interfaces': path.resolve(__dirname, 'src/interfaces'),
'@routes': path.resolve(__dirname, 'src/routes'),
},
},
}
})