-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
38 lines (35 loc) · 1.02 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
import react from '@vitejs/plugin-react'
import * as path from 'node:path'
import autoExternal from 'rollup-plugin-auto-external'
import { BuildOptions, defineConfig } from 'vite'
const libraryBuildOptions: BuildOptions = {
lib: {
entry: path.resolve(__dirname, 'src', 'index.tsx'),
name: 'GraphiQLPlayground',
formats: ['es', 'cjs'],
fileName: (format) => `index.${format === 'cjs' ? 'cjs' : 'mjs'}`,
},
rollupOptions: {
external: ['react/jsx-runtime', 'theme-ui/jsx-runtime', '@emotion/react/jsx-runtime', 'next/router', 'next'],
plugins: [autoExternal() as any],
},
}
const demoBuildOptions: BuildOptions = {
chunkSizeWarningLimit: 1000,
}
export default defineConfig({
plugins: [react()],
build: process.env.BUILD_DEMO ? demoBuildOptions : libraryBuildOptions,
esbuild: {
jsx: 'automatic',
logOverride: {
// https://github.com/vitejs/vite/issues/8644
'this-is-undefined-in-esm': 'silent',
},
},
resolve: {
alias: {
'next/router': 'wouter',
},
},
})