-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
68 lines (63 loc) · 1.48 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const babel = require('rollup-plugin-babel')
import typescript from 'typescript'
import typescript2 from 'rollup-plugin-typescript2'
import filesize from 'rollup-plugin-filesize'
import { terser } from 'rollup-plugin-terser'
const pkg = require('./package.json')
const resolve = function (...args) {
return path.resolve(__dirname, ...args)
}
const extensions = ['.js', '.ts']
const banner =
`/*!
* websocket-reconnect v${pkg.version}
* (c) 2020-${new Date().getFullYear()} chenwuai
* Released under the MIT License.
*/`
export default {
input: resolve('./src/index.ts'),
plugins: [
typescript2({
exclude: 'node_modules/**',
useTsconfigDeclarationDir: true,
typescript,
tsconfig: './tsconfig.json'
}),
babel({
exclude: 'node_modules/**',
extensions
}),
filesize()
],
output: [
{
format: 'cjs',
// 生成的文件名和路径
// package.json的main字段, 也就是模块的入口文件
file: pkg.main,
banner,
plugins: [terser({ compress: { drop_console: true }})]
},
{
format: 'es',
// rollup和webpack识别的入口文件, 如果没有该字段, 那么会去读取main字段
file: pkg.module,
banner,
sourcemap: true
},
{
format: 'umd',
name: 'WebsocketReconnect',
file: pkg.browser,
banner,
plugins: [terser()]
},
{
file: 'lib/websocket-reconnect-iife.js',
format: 'iife',
name: 'WebsocketReconnect'
}
]
}