-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathvite.config.js
43 lines (42 loc) · 1.47 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import { resolve } from 'path'
// https://vite.dev/config/
export default defineConfig({
mode: process.env.NODE_ENV,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
build: {
outDir: 'lib/js',
emptyOutDir: false,
sourcemap: process.env.NODE_ENV == 'production',
lib: {
entry: {
react: resolve(__dirname, 'js_src/index.mjs')
},
name: "ReactBundle", // This doesn't do anything but is required.
fileName: (format, entryName) => `${entryName}.${process.env.NODE_ENV == 'production' ? 'min' : 'dev'}.js`,
formats: ['iife'],
},
minify: process.env.NODE_ENV == 'production',
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled into your library
external: [
// `react-redux` requires `redux` but we do not utilize the one section that it is used.
// For reference, react-redux.js uses `redux` only one time ever, in [whenMapDispatchToPropsIsObject]
// and it calls `redux.bindActionCreators`.
//
// This line fakes any `require('redux')` calls, so that webpack will not include all of the `redux` code.
'redux',
],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
// see comment in `rollupOptions.external` above for `redux`.
redux: 'window.Object',
},
},
},
},
})