-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
64 lines (59 loc) · 1.6 KB
/
Copy pathvite.config.ts
File metadata and controls
64 lines (59 loc) · 1.6 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
import { defineConfig, LibraryFormats } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const demoConfig = {
base: "./",
root: resolve(dirname(fileURLToPath(import.meta.url)), "./"),
plugins: [react()],
build: {
outDir: resolve(dirname(fileURLToPath(import.meta.url)), "docs"),
emptyOutDir: true,
},
};
const libConfig = {
plugins: [
react(),
dts({
insertTypesEntry: true,
exclude: ["src/main.tsx", "src/App.tsx", "src/Basic.tsx"],
}),
],
build: {
lib: {
entry: {
"use-all": resolve(__dirname, "src/index.ts"),
"use-audio": resolve(__dirname, "src/hooks/audio.ts"),
"use-media": resolve(__dirname, "src/hooks/media.ts"),
"use-blob": resolve(__dirname, "src/hooks/blob.ts"),
"use-interval": resolve(__dirname, "src/hooks/interval.ts"),
"audio-context": resolve(
__dirname,
"src/contextProviders/audioContextProvider.tsx"
),
},
name: "ReactUseMedia",
formats: ["es", "cjs"] as LibraryFormats[],
},
rollupOptions: {
external: ["react"],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
react: "React",
},
},
},
},
};
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
if (mode === "demo") {
return demoConfig;
} else {
return libConfig;
}
});