-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
54 lines (47 loc) · 1.35 KB
/
vite.config.js
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
import { exec } from 'node:child_process'
import { promisify } from 'node:util'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
const execAsync = promisify(exec)
const disableHmr = process.env.DISABLE_HMR === 'true'
const disableOpen = process.env.DISABLE_OPEN === 'true'
const frontendPort = process.env.PORT ? parseInt(process.env.PORT) : 3001
export default defineConfig(async () => {
const codeVersionId = await getCodeVersionId()
return {
base: '/pdf/',
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin', '@babel/plugin-syntax-import-assertions'],
},
}),
],
build: {
sourcemap: true,
chunkSizeWarningLimit: 300 * 1024,
rollupOptions: {
output: {
// By default, the names of the files are exposed
entryFileNames: 'assets/[hash].js',
chunkFileNames: 'assets/[hash].js',
assetFileNames: 'assets/[hash].[ext]',
},
},
},
define: {
__CODE_VERSION_ID__: JSON.stringify(codeVersionId),
'process.env': {},
},
server: {
port: frontendPort,
open: !disableOpen,
hmr: !disableHmr,
},
}
})
async function getCodeVersionId() {
const { stdout: version } = await execAsync('./get-version.sh')
return version
}