forked from solidcouch/solidcouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
62 lines (59 loc) · 1.69 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
import { lingui } from '@lingui/vite-plugin'
import react from '@vitejs/plugin-react-swc'
import { execSync } from 'node:child_process'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { ConfigEnv, defineConfig } from 'vite'
import checker from 'vite-plugin-checker'
import { version } from './package.json'
import { fetchCommunityEnv } from './plugins/fetchCommunityEnv'
import { postbuild } from './plugins/postbuild'
import { serveClientId } from './plugins/serveClientId'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
let commit: string = ''
try {
commit = execSync('git rev-parse HEAD').toString().trim()
} catch {
// eslint-disable-next-line no-console
console.warn("Couldn't get the commit hash")
}
// https://vite.dev/config/
// eslint-disable-next-line import/no-default-export
export default defineConfig((config: ConfigEnv) => {
return {
plugins: [
fetchCommunityEnv(config),
react({
plugins: [
[
'@lingui/swc-plugin',
{
runtimeModules: {
i18n: ['@lingui/core', 'i18n'],
trans: ['@lingui/react', 'Trans'],
},
},
],
],
}),
lingui(),
checker({
typescript: { buildMode: true },
eslint: { lintCommand: 'eslint .', useFlatConfig: true },
}),
serveClientId(config),
postbuild(config),
],
define: {
'process.env': process.env,
__APP_VERSION__: JSON.stringify(version),
__APP_COMMIT__: JSON.stringify(commit),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
}
})