forked from clouDr-f2e/monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
101 lines (101 loc) · 2.07 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
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2'
import { terser } from 'rollup-plugin-terser'
const esmPackage = {
input: 'src/index.ts',
output: {
file: 'dist/mito.js',
format: 'esm',
//iife/umd 包,同一页上的其他脚本可以访问它 生成var MyBundle = (function(){})()
name: 'MITO',
sourcemap: true
},
plugins: [
resolve(),
commonjs({
exclude: 'node_modules'
}),
json(),
typescript({
useTsconfigDeclarationDir: true,
declarationDir: 'dist/types/'
})
]
}
const localDebug = {
input: 'src/index.ts',
output: {
file: '/Users/ks/Desktop/tryCatch/github/mito-vue-demo/src/bundle.js',
format: 'esm',
name: 'MITO',
context: 'window'
},
plugins: [
resolve(),
commonjs({
exclude: 'node_modules'
}),
json(),
typescript({
tsconfigOverride: { compilerOptions: { declaration: false } }
})
]
}
const iifePackage = {
input: 'src/index.ts',
output: {
file: 'dist/mito.min.js',
format: 'iife',
name: 'MITO',
context: 'window'
},
plugins: [
resolve(),
commonjs({
exclude: 'node_modules'
}),
json(),
typescript({
tsconfigOverride: { compilerOptions: { declaration: false } }
}),
terser()
]
}
const examplePackage = {
input: 'src/index.ts',
output: {
file: 'examples/mito.js',
format: 'iife',
name: 'MITO'
},
plugins: [
resolve(),
commonjs({
exclude: 'node_modules'
}),
json(),
typescript({
tsconfigOverride: { compilerOptions: { declaration: false } }
})
]
}
const total = {
esmPackage,
iifePackage,
examplePackage,
localDebug
}
let result = total
const ignore = process.env.IGNORE
const include = process.env.INCLUDE
console.log(`ignore: ${ignore}, include: ${include}`)
if (ignore) {
delete total[ignore]
result = total
}
if (include) {
result = [total[include]]
}
export default [...Object.values(result)]