generated from tomsouthall/react-library-vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
77 lines (76 loc) · 2.42 KB
/
vite.config.js
File metadata and controls
77 lines (76 loc) · 2.42 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import path from 'path'
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import EnvironmentPlugin from 'vite-plugin-environment';
import ViteRequireContext from '@originjs/vite-plugin-require-context';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// import {nodePolyfills} from 'vite-plugin-node-polyfills'
import nodePolyfills from 'rollup-plugin-node-polyfills';
// https://vitejs.dev/config/
export default defineConfig({
// define: {
// 'process.env': process.env ?? {},
// },
resolve: {
alias: {
util: require.resolve("util/"),
},
},
build: {
target: "es2020",
lib: {
entry: path.resolve(__dirname, 'src/lib/index.jsx'),
name: 'React Tensorflow Js Models',
fileName: (format) => `react-tfjs-models.${format}.js`
},
rollupOptions: {
// target: 'esnext',
rollupOptions: {
plugins: [
nodePolyfills({ crypto: true }),
],
},
// externalize deps that shouldn't be bundled
// into your library
external: ['react', 'react-dom'],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
react: 'React'
}
}
}
},
plugins: [
ViteRequireContext(),
react(),
EnvironmentPlugin('all'),
// nodePolyfills({
// // To exclude specific polyfills, add them to this list.
// exclude: [
// 'fs', // Excludes the polyfill for `fs` and `node:fs`.
// ],
// // Whether to polyfill specific globals.
// globals: {
// Buffer: true, // can also be 'build', 'dev', or false
// global: true,
// process: true,
// },
// // Whether to polyfill `node:` protocol imports.
// protocolImports: true,
// })
],
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
plugins: [
NodeGlobalsPolyfillPlugin({ buffer: true }),
],
target: "es2020",
}
},
})