-
Notifications
You must be signed in to change notification settings - Fork 294
Expand file tree
/
Copy pathvite.config.ts
More file actions
47 lines (43 loc) · 1.46 KB
/
vite.config.ts
File metadata and controls
47 lines (43 loc) · 1.46 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
import { resolve } from 'path';
import { defineConfig, type LibraryFormats } from 'vite';
import { dependencies, peerDependencies } from './package.json';
import { compilerOptions } from './tsconfig.lib.json';
import getPackageVersion from './scripts/get-package-version.mjs';
const external = [
...Object.keys(dependencies),
...Object.keys(peerDependencies),
// regex patterns to match subpaths of external dependencies
// e.g. @stream-io/abc and @stream-io/abc/xyz (without this, Vite bundles subpaths)
].map((dependency) => new RegExp(`^${dependency}(\\/[\\w-]+)?$`));
const formats: LibraryFormats[] = ['es', 'cjs'];
export default defineConfig({
build: {
lib: {
entry: {
index: resolve(__dirname, './src/index.ts'),
emojis: resolve(__dirname, './src/plugins/Emojis/index.ts'),
'mp3-encoder': resolve(__dirname, './src/plugins/encoders/mp3.ts'),
},
},
emptyOutDir: false,
outDir: 'dist',
minify: false,
sourcemap: true,
target: compilerOptions.target,
rollupOptions: {
external,
output: formats.map((format) => {
const extension = format === 'es' ? 'mjs' : 'js';
return {
format,
chunkFileNames: `[format]/[name].[hash].${extension}`,
entryFileNames: `[format]/[name].${extension}`,
hashCharacters: 'hex',
};
}),
},
},
define: {
'process.env.STREAM_CHAT_REACT_VERSION': JSON.stringify(getPackageVersion()),
},
});