-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrollup.config.js
113 lines (109 loc) · 3.21 KB
/
rollup.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import json from '@rollup/plugin-json';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import copy from 'rollup-plugin-copy';
import pkg from './package.json';
const common = {
input: 'src/index.ts',
plugins: [
commonjs({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
}),
replace({
'process.env.APP_VERSION': pkg.version,
}),
json(),
],
};
const getUmdConfig = (fileName, input) => ({
...common,
input,
output: {
...common.output,
file: fileName,
format: 'umd',
name: 'assistant',
plugins: [terser()],
},
plugins: [
nodeResolve({
browser: true,
preferBuiltins: true,
}),
typescript({ tsconfig: 'tsconfig.json', declaration: false, declarationMap: false }),
...common.plugins,
],
});
export default [
{
...common,
input: ['src/index.ts', 'src/createAssistantDevOrigin.ts'],
output: {
...common.output,
dir: 'dist',
format: 'cjs',
},
plugins: [
nodeResolve({
browser: true,
preferBuiltins: true,
}),
typescript({ tsconfig: 'tsconfig.json', outDir: 'dist' }),
...common.plugins,
copy({
targets: [
{
src: 'src/proto/*.d.ts',
dest: 'dist/proto',
},
{
src: 'src/assistantSdk/voice/recognizers/asr/*.d.ts',
dest: 'dist/assistantSdk/voice/recognizers/asr'
},
{
src: 'src/assistantSdk/voice/recognizers/mtt/*.d.ts',
dest: 'dist/assistantSdk/voice/recognizers/mtt'
},
],
}),
],
},
{
...common,
input: [
'src/createAssistant.ts',
'src/createAssistantDev.ts',
'src/createAssistantDevOrigin.ts',
'src/assistantSdk/assistant.ts',
'src/mock.ts',
'src/index.ts',
],
output: {
...common.output,
dir: 'esm',
format: 'esm',
manualChunks: {
sdk: ['src/proto/index.js', 'src/assistantSdk/client/protocol.ts', 'src/typings.ts'],
record: ['src/record/index.ts'],
common: ['node_modules/tslib', 'src/nanoevents.ts', 'src/nanoobservable.ts'],
},
},
plugins: [
nodeResolve({
browser: true,
preferBuiltins: true,
}),
typescript({ outDir: 'esm', declaration: false, declarationMap: false, module: 'esnext' }),
...common.plugins,
],
},
{
...getUmdConfig(pkg.unpkgdev, 'src/createAssistantDevOrigin.ts'),
},
{
...getUmdConfig(pkg.unpkg, 'src/createAssistant.ts'),
},
];