-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
vite.config.ts
56 lines (53 loc) · 1.43 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
import { defineConfig } from 'vite';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import { buildPackage } from './rollup.common';
import { RollupOptions } from 'rollup';
import { replaceCodePlugin } from 'vite-plugin-replace';
type Props = {
entry: string;
rollupOptions: RollupOptions;
};
// reused for vite.config.tools & vite.config.production
export const createConfig = ({ entry, rollupOptions }: Props) =>
defineConfig({
clearScreen: false,
build: {
target: 'es2017',
emptyOutDir: false,
minify: false,
sourcemap: true,
lib: {
entry,
},
rollupOptions,
},
plugins: [
// this check in emotion package is not safe enough
// https://github.com/emotion-js/emotion/issues/3196
replaceCodePlugin({
replacements: [
{
from: "typeof HTMLElement !== 'undefined'",
to: "(typeof document !== 'undefined' && typeof HTMLElement !== 'undefined')",
},
],
}),
react(),
replaceCodePlugin({
replacements: [
{
from: 'process.env.TOLGEE_UI_VERSION',
to: JSON.stringify(process.env.TOLGEE_UI_VERSION) || 'undefined',
},
],
}),
],
});
export default createConfig({
entry: resolve(__dirname, 'src/package/entry-development.ts'),
rollupOptions: buildPackage({
name: 'web',
env: 'development',
}),
});