generated from UNDP-Data/dv-ui-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
46 lines (45 loc) · 1.18 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
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import eslint from 'vite-plugin-eslint';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [dts({ rollupTypes: true }), react(), eslint()],
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
build: {
cssCodeSplit: false,
lib: {
entry: 'src/index.ts',
name: 'undpViz',
fileName: format => {
if (format === 'es') return 'index.js'; // ES Module
if (format === 'cjs') return 'index.cjs'; // CommonJS Module
return 'index.umd.js'; // UMD Module
},
formats: ['es', 'cjs', 'umd'],
},
rollupOptions: {
// Externalize deps that shouldn't be bundled into the library.
external: ['react', 'react-dom'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
sourcemap: true,
emptyOutDir: true,
},
server: {
cors: {
origin: '*',
methods: ['GET'],
preflightContinue: false,
optionsSuccessStatus: 204,
},
},
});