-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.ts
47 lines (44 loc) · 1.14 KB
/
vite.config.ts
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import dts from "vite-plugin-dts";
import * as fs from "fs/promises";
/**
* `rollup-plugin-dts` really wants to rename `JSX` to `JSX_2`, so we undo that
* here.
*/
async function renameJsx() {
const input = await fs.readFile("./dist/talkjs-react.d.ts", "utf8");
const output = input
.replace(
`import { JSX as JSX_2 } from 'react/jsx-runtime';`,
`import { JSX } from 'react/jsx-runtime';`,
)
.replace(/JSX_2/g, "JSX");
await fs.writeFile("./dist/talkjs-react.d.ts", output);
}
// https://vitejs.dev/config/
export default defineConfig({
build: {
target: "es2015",
lib: {
entry: "lib/main.tsx",
name: "TalkJSReact",
fileName: "talkjs-react",
formats: ["es", "umd", "cjs"],
},
rollupOptions: {
external: ["react", "react/jsx-runtime", "talkjs"],
output: {
globals: {
react: "React",
talkjs: "TalkJS",
},
banner: `"use client";`,
},
},
},
plugins: [
react(),
dts({ include: "lib", rollupTypes: true, afterBuild: renameJsx }),
],
});