forked from LancerComet/vue-jsonp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (50 loc) · 1.32 KB
/
gulpfile.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
const fs = require('fs')
const path = require('path')
const browserify = require('browserify')
const gulp = require('gulp')
const rename = require('gulp-rename')
const umd = require('gulp-umd')
const util = require('gulp-util')
const ROOTPATH = path.resolve(__dirname)
const ENTRY = `${ROOTPATH}/src/index.js`
gulp.task('default', ['js:umd'])
gulp.task('js:build', () => {
new browserify({ entries: [ENTRY] })
.transform('babelify', { presets: ["es2015", "stage-2"] })
.plugin('minifyify', {
map: false,
uglify: {
compress: {
drop_console: true,
dead_code: true,
conditionals: true,
unused: true,
if_return: true,
global_defs: {
DEBUG: false
}
},
mangle: true
}
})
.on('log', util.log)
.on('error', function (error) {
console.error(error.toString())
this.emit('end')
})
.bundle(function () {}) // Empty function for using minifyify.
.pipe(fs.createWriteStream(`${ROOTPATH}/dist/vue-jsonp.min.js`))
})
gulp.task('js:umd', (file) => {
gulp.src(ENTRY)
.pipe(umd({
exports (file) {
return 'vueJsonp'
},
namespace (file) {
return 'vueJsonp'
}
}))
.pipe(rename('vue-jsonp.umd.js'))
.pipe(gulp.dest(`${ROOTPATH}/dist`))
})