-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvite.config.ts
More file actions
40 lines (37 loc) · 1.03 KB
/
vite.config.ts
File metadata and controls
40 lines (37 loc) · 1.03 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
import react from '@vitejs/plugin-react'
import { defineConfig, loadEnv } from 'vite'
import graphqlCodegen from 'vite-plugin-graphql-codegen'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import svgr from 'vite-plugin-svgr'
export function capitalizeFirstLetter(word?: string) {
if (!word) return ''
return word.charAt(0).toUpperCase() + word.slice(1)
}
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
plugins: [
graphqlCodegen({
configFilePathOverride: 'codegen.ts',
enableWatcher: true,
}),
react({
babel: {
plugins: ['@emotion/babel-plugin'],
},
}),
svgr(),
nodePolyfills(),
{
name: 'html-transform',
transformIndexHtml(html) {
return html.replace(
/<title>(.*?)<\/title>/,
`<title>Fluence ${capitalizeFirstLetter(env.VITE_CHAIN || 'local')} Explorer </title>`,
)
},
},
],
}
})