-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
53 lines (45 loc) · 1.15 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
import cjs from '@rollup/plugin-commonjs'
import path from 'path'
import cleanup from 'rollup-plugin-cleanup'
import resolve from 'rollup-plugin-node-resolve'
import ts from 'rollup-plugin-typescript2'
import packageJSON from './package.json'
const getPath = _path => path.resolve(__dirname, _path)
const extensions = ['.ts']
const tsPlugin = ts({
tsconfig: getPath('./tsconfig.json'), // 导入本地ts配置
extensions,
useTsconfigDeclarationDir: true
})
const commonConf = {
input: getPath('./src/index.ts'),
plugins: [
resolve(extensions),
tsPlugin,
cjs(),
cleanup()
],
external: ['axios'],
}
const outputMap = [
{
file: packageJSON.main,
format: "umd",
globals: {
'axios': 'axios'
}
},
{
file: packageJSON.module, // es6模块
format: 'es'
},
{
file: packageJSON.cjs, // cmd模块
format: 'cjs',
}
]
const buildConf = options => Object.assign({}, commonConf, options)
const rollupConfig = outputMap.map(output => buildConf({
output: { name: packageJSON.name, ...output }
}));
export default rollupConfig;