-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.js
37 lines (36 loc) · 940 Bytes
/
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
const { resolve } = require("path");
const { defineConfig } = require("vite");
import reactRefresh from "@vitejs/plugin-react-refresh";
import react from "@vitejs/plugin-react";
/*
The config is defined to run the build based on the mode it is run.
For mode=website, the react app is built and served.
For mode=package, the mockman package is built and can be published.
*/
export default defineConfig(({ mode }) => {
if (mode === "package") {
return {
plugins: [reactRefresh()],
minify: true,
build: {
lib: {
entry: resolve(__dirname, "lib/main.jsx"),
name: "mockman",
fileName: (format) => `mockman.${format}.js`,
},
rollupOptions: {
external: ["react"],
output: {
globals: {
react: "React",
},
},
},
},
};
} else {
return {
plugins: [react()],
};
}
});