-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
53 lines (51 loc) · 1.68 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
import { transformAsync } from '@babel/core';
import refresh from '@vitejs/plugin-react-refresh';
import { defineConfig } from 'vite';
import { compilerOptions } from './tsconfig.build.json';
export default defineConfig({
resolve: {
alias: Object.fromEntries(
Object.entries(compilerOptions.paths).map(([key, value]) => [
key.replace('*', ''),
`/${value[0].replace('*', '')}`,
]),
),
},
build: {
outDir: 'build',
minify: 'esbuild',
},
plugins: [
refresh(),
{
name: 'lingui-macro',
enforce: 'pre',
async transform(source, filename) {
if (filename.includes('node_modules')) {
return;
}
if (!source.includes('@lingui/macro')) {
return;
}
const result = await transformAsync(source, {
filename,
parserOpts: {
plugins: ['jsx', 'typescript'],
},
plugins: ['babel-plugin-macros'],
babelrc: false,
configFile: false,
generatorOpts: {
jsescOption: {
// This option is mandatory.
// Otherwise, UTF-8 strings will be escaped in the produced code,
// which cannot be translated by @lingui/macro.
minimal: true,
},
},
});
return result?.code;
},
},
],
});