-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
53 lines (51 loc) · 1021 Bytes
/
build.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
const rollup = require('rollup')
const buble = require('@rollup/plugin-buble')
const commonjs = require('@rollup/plugin-commonjs')
const uglify = require('rollup-plugin-uglify')
const pkg = require('./package.json')
async function build(output, plugins = []) {
try {
const bundle = await rollup.rollup({
input: 'lib/index.js',
plugins: [
buble({
transforms: {
dangerousForOf: true
}
}),
commonjs(),
...plugins
]
})
await bundle.write({
output,
banner: `/*! ${pkg.name} v${pkg.version} */\n`
})
} catch(e) {
console.log(e)
}
}
build({
file: 'index.js',
format: 'cjs',
exports: 'named'
})
build({
file: 'schema-validate.js',
format: 'iife',
name: 'SchemaValidate',
exports: 'named'
})
build({
file: 'schema-validate.min.js',
format: 'iife',
name: 'SchemaValidate',
exports: 'named'
}, [
uglify.uglify({
output: {
comments: /^!/,
max_line_len: 1000
}
})
])