-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
61 lines (58 loc) · 1.75 KB
/
Copy pathvite.config.js
File metadata and controls
61 lines (58 loc) · 1.75 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
//import react from "@vitejs/plugin-react";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
build: {
emptyOutDir: false,
copyPublicDir: false,
cssCodeSplit: false, // single CSS file
lib: {
entry: "src/bundle.js", // same entry
name: "nexSys", // global var in IIFE build
fileName: () => "nexsys.min.js",
formats: ["iife"], // one self‑executing <script>
},
/* Rollup options for externals & globals */
rollupOptions: {
external: ["react", "react-dom", "react-dom/client", "nexevent"],
output: {
globals: {
react: "React", // case‑exact like your webpack externals
"react-dom": "ReactDOM",
"react-dom/client": "ReactDOM",
nexevent: "eventStream", // Nexus global
},
inlineDynamicImports: true,
},
},
/* Minification ------------------------------------ */
minify: "terser", // esbuild is default but terser is safer
terserOptions: {
ecma: 2020,
mangle: true,
keep_fnames: true,
keep_classnames: true,
compress: {
// Stop the specific transform that inlines your handler
inline: 0, // disable function inlining
reduce_funcs: false, // don't fold function expressions
reduce_vars: false, // don't inline single-use consts
passes: 1,
keep_fargs: true,
},
},
},
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./src/localMockUp.js", "./src/tests/setupTests.js"],
coverage: {
reporter: ["text", "json", "html"],
},
},
});