-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
73 lines (61 loc) · 1.78 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
//import { tslint } from 'rollup-plugin-tslint'
import resolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import typescript from 'rollup-plugin-typescript2'
import { uglify as uglifyJS } from 'rollup-plugin-uglify'
import { terser } from 'rollup-plugin-terser'
import gzip from 'rollup-plugin-gzip'
const configs = []
for (const pkg of ['core', 'validators']) {
for (const format of ['umd', 'cjs', 'amd', 'esm']) {
for (const productive of [false, true]) {
configs.push(createConfig(pkg, format, productive))
}
}
}
export default configs
// --- locals -------------------------------------------------------
function createConfig(pkg, moduleFormat, productive) {
let file
if (pkg === 'core') {
file = productive
? `dist/js-spec.${moduleFormat}.production.js`
: `dist/js-spec.${moduleFormat}.development.js`
} else if (pkg === 'validators') {
file = productive
? `dist/js-spec.validators.${moduleFormat}.production.js`
: `dist/js-spec.validators.${moduleFormat}.development.js`
}
return {
input:
pkg === 'core'
? 'src/main/js-spec.ts'
: 'src/main/api/validators.ts',
output: {
file,
format: moduleFormat,
name: pkg === 'core' ? 'jsSpec' : 'jsSpec.validators',
sourcemap: false,
globals: {
'js-spec': 'jsSpec',
}
},
external: [],
plugins: [
resolve(),
// tslint({
//}),
replace({
exclude: 'node_modules/**',
values: {
'process.env.NODE_ENV': productive ? "'production'" : "'development'"
}
}),
typescript({
exclude: 'node_modules/**',
}),
productive && (moduleFormat === 'esm' ? terser() : uglifyJS()),
productive && gzip()
],
}
}