-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathvite.config.mjs
More file actions
40 lines (38 loc) · 1.06 KB
/
vite.config.mjs
File metadata and controls
40 lines (38 loc) · 1.06 KB
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
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [react()],
server: {
port: parseInt(env.PORT) || 9966,
strictPort: false, // Allow Vite to find next available port if default is taken
allowedHosts: true,
// Conditional HMR management for production environments
hmr: process.env.NODE_ENV === 'production' || process.env.DISABLE_HMR ? false : {
port: parseInt(env.PORT) || 9966
}
},
build: {
target: 'esnext',
lib: {
entry: 'index.jsx',
name: 'ReactPivot',
fileName: (format) => format === 'umd' ? 'react-pivot.umd.cjs' : `react-pivot.${format}.js`
},
rollupOptions: {
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM'
}
}
}
},
json: {
stringify: true
}
}
})