-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathvite.config.js
More file actions
136 lines (127 loc) · 2.74 KB
/
vite.config.js
File metadata and controls
136 lines (127 loc) · 2.74 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
135
136
import vue from '@vitejs/plugin-vue2'
import gitprocess from 'child_process'
import path from 'path'
import { visualizer } from 'rollup-plugin-visualizer'
import { defineConfig, loadEnv } from 'vite'
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
import { qrcode } from 'vite-plugin-qrcode'
import svgLoader from 'vite-svg-loader'
import crypto from 'crypto'
let date
if (typeof gitprocess === 'function') {
date = new Date(
gitprocess
.execSync('git log -1 --date=format:"%Y/%m/%d %T" --format="%ad"')
.toString()
)
} else {
date = new Date()
}
process.env.VITE_APP_VERSION = require('./package.json').version
process.env.VITE_APP_BUILD_DATE =
date.getDate() +
' ' +
date.toLocaleString('en-US', { month: 'short' }).toLowerCase()
process.env.VITE_APP_EXCHANGES = [
'AGGR',
'ASTER',
'BITMEX',
'BINANCE_FUTURES',
'BINANCE_US',
'KRAKEN',
'HUOBI',
'BINANCE',
'BITFINEX',
'BITSTAMP',
'COINBASE',
'HITBTC',
'OKEX',
'POLONIEX',
'DERIBIT',
'BYBIT',
'PHEMEX',
'DYDX',
'MEXC',
'MEXC_FUTURES',
'KUCOIN',
'BITGET',
'BITUNIX',
'GATEIO',
'CRYPTOCOM',
'BITMART',
'HYPERLIQUID',
'WHITEBIT'
]
export default defineConfig(({ mode }) => {
const env = {
...process.env,
...loadEnv(mode, process.cwd(), '')
}
const processEnvValues = {
'process.env': Object.entries(env).reduce((prev, [key, val]) => {
if (key.startsWith('VITE_') || key === 'NODE_ENV') {
return {
...prev,
[key]: val
}
}
return prev
}, {})
}
const hash = crypto
.createHash('md5')
.update('aggr')
.digest('hex')
.substring(0, 7)
return {
define: {
...processEnvValues
},
base: mode === 'github' ? env.VITE_APP_BASE_PATH : '/',
plugins: [
vue(),
svgLoader({
defaultImport: 'url' // 👈
}),
visualizer(),
monacoEditorPlugin.default({}),
qrcode() // only applies in dev mode
// Add the terser plugin for production builds to remove console.log
],
build: {
minify: 'terser',
rollupOptions: {
output: {
entryFileNames: `[name].` + hash + `.js`,
chunkFileNames: `[name].` + hash + `.js`,
assetFileNames: `[name].` + hash + `.[ext]`
}
},
terserOptions: {
compress: {
drop_console: true
}
}
},
server: {
port: 8080,
host: '0.0.0.0'
},
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src')
}
]
},
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
additionalData: `@import "@/assets/sass/variables.scss";`
}
}
}
}
})