-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathvite.config.js
39 lines (35 loc) · 859 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
38
39
import { defineConfig } from "vite";
import * as path from "node:path";
import react from "@vitejs/plugin-react";
const isCodeSandbox =
"SANDBOX_URL" in process.env || "CODESANDBOX_HOST" in process.env;
const dev = defineConfig({
plugins: [react()],
root: "example/",
publicDir: "../public/",
base: "./",
server: {
host: true,
open: !isCodeSandbox, // Open if it's not a CodeSandbox
},
});
const build = defineConfig({
publicDir: false,
build: {
minify: false,
sourcemap: true,
target: "es2018",
lib: {
formats: ["cjs", "es"],
entry: "src/Ecctrl.tsx",
fileName: "[name]",
},
rollupOptions: {
external: (id) => !id.startsWith(".") && !path.isAbsolute(id),
output: {
sourcemapExcludeSources: true,
},
},
},
});
export default process.argv[2] ? build : dev;