forked from AgoraIO-Usecase/AgoraChat-UIKit-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
93 lines (91 loc) · 2.25 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import path from 'path';
import svgr from 'vite-plugin-svgr';
// const path = require("path");
// const jsx = require("acorn-jsx");
import jsx from 'acorn-jsx';
const __dirname = path.resolve();
const resolvePath = (str: string) => path.resolve(__dirname, str);
// import { UserConfig } from "vitest";
// const rollupOptions = {
// external: ['rect', 'react-dom'],
// output: {
// globals: {
// react: 'React',
// 'react-dom': 'react-dom',
// },
// },
// acornInjectPlugins: [jsx()],
// plugins: [
// typescript({
// compilerOptions: {
// jsx: 'preserve',
// // outDir: "./dist/types",
// declaration: true,
// declarationDir: './dist',
// // declarationDir: "dist",
// },
// // target: "es2015", // 这里指定编译到的版本,
// // include: ["src/"],
// exclude: ['node_modules', 'dist'],
// // allowSyntheticDefaultImports: true,
// }),
// ],
// };
export default defineConfig({
plugins: [
svgr({
svgrOptions: {
icon: true,
},
}),
dts({
outputDir: './build/types',
insertTypesEntry: true, // 插入TS 入口
copyDtsFiles: true, // 是否将源码里的 .d.ts 文件复制到 outputDir
}),
],
build: {
// rollupOptions,
minify: false,
// lib: {
// entry: './src/entry.ts',
// name: 'ChatUI',
// fileName: 'ChatUI',
// // 导出模块格式
// formats: ['esm', 'umd', 'iife'],
// },
// outDir: './dist',
lib: {
entry: './index.ts',
name: 'ChatUI',
fileName: 'ChatUI',
// 导出模块格式
formats: ['esm', 'umd', 'cjs'],
},
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['react', 'react-dom'],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
react: 'react',
'react-dom': 'react-dom',
},
},
},
outDir: './build',
},
test: {
globals: true,
environment: 'happy-dom',
},
resolve: {
// 配置路径别名
alias: {
'~': path.resolve(__dirname),
},
},
} as any);