-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathvite.config.ts
48 lines (45 loc) · 1.33 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
import { defineConfig, loadEnv } from 'vite';
import { viteSingleFile } from 'vite-plugin-singlefile';
import react from '@vitejs/plugin-react';
import path from 'path';
import dts from 'vite-plugin-dts';
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const singleFileOutput = process.env.VITE_SINGLE_FILE_OUTPUT === 'true';
// https://vitejs.dev/config/
return defineConfig({
build: {
minify: 'terser',
// Required to make require() work e.g for graphql-ws
commonjsOptions: {
transformMixedEsModules: true,
},
lib: !singleFileOutput
? {
entry: path.resolve(__dirname, './src/index.ts'),
name: '@wundergraph/playground',
fileName: (format) => `index.${format}.js`,
}
: false,
sourcemap: !singleFileOutput,
emptyOutDir: true,
rollupOptions: !singleFileOutput
? {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
}
: undefined,
},
plugins: [react(), !singleFileOutput ? dts() : viteSingleFile()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
});
};