-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
62 lines (56 loc) · 1.31 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
import rm from 'rimraf'
import path from 'path'
import ts from 'rollup-plugin-typescript2'
import { terser } from 'rollup-plugin-terser'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import globals from 'rollup-plugin-node-globals'
rm.sync(path.resolve('dist/**/*'))
const packageName = 'form-validation'
const pascalCasePackageName = 'FormValidation'
const input = 'src/index.ts'
const isProd = process.env.npm_lifecycle_script.indexOf('--watch') === -1
const formats = isProd ? ['es', 'umd', 'amd', 'cjs', 'iife', 'system'] : ['es', 'umd', 'cjs']
const configs = []
formats.forEach(format => {
const config = {
input,
output: {
format,
name: pascalCasePackageName,
extend: true,
},
}
configs.push({
...config,
plugins: [
ts(),
replace({
__DEV__: true,
}),
resolve(),
globals(),
],
output: {
...config.output,
file: path.resolve(`dist/${packageName}.${format}.js`),
},
})
configs.push({
...config,
plugins: [
ts(),
replace({
__DEV__: false,
}),
resolve(),
globals(),
terser(),
],
output: {
...config.output,
file: path.resolve(`dist/${packageName}.${format}.prod.js`),
},
})
})
export default configs