-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
29 lines (26 loc) · 886 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
const {transformFileSync} = require('babel-core')
const fs = require('fs')
const path = require('path')
const uglify = require('uglify-js')
const umd = require('umd')
const shell = require('shelljs')
shell.rm('-rf', 'dist')
shell.mkdir('-p', 'dist')
const result = transformFileSync(path.join(__dirname, './index.js'), {
sourceType: "script",
presets: [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"],
"node": "8.9",
"uglify": true
},
"modules": false,
"include": ["es6.object.assign"],
"debug": true,
}]
]
})
const libName = 'Validator'
fs.writeFileSync(path.join(__dirname, './dist/validator.js'), umd(libName, result.code + `\n\nreturn ${libName}`))
fs.writeFileSync(path.join(__dirname, './dist/validator.min.js'), uglify.minify(umd(libName, result.code + `\n\nreturn ${libName}`)).code)