-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
57 lines (49 loc) · 1.62 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
56
57
'use strict'
let packageJson = require('./package.json')
let version = packageJson.version
var gulp = require('gulp')
var webpack = require('webpack-stream')
var mocha = require('gulp-mocha') // 用于单元测试
var babel = require('gulp-babel') // 用于ES6转化ES5
// var browserify = require('browserify');
// var source = require('vinyl-source-stream');
// var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify')
var rename = require('gulp-rename')
var sourcemaps = require('gulp-sourcemaps')
var gutil = require('gulp-util')
var es2015 = require('babel-preset-es2015');
// websdk-{version}.js
gulp.task('sdk:umd', function () {
return gulp.src('./index.js')
.pipe(webpack({
output: {
filename: 'websdk-' + version + '.js',
library: 'WebIM',
libraryTarget: 'umd'
}
})
)
.pipe(gulp.dest('dist/'))
})
// websdk-{version}.min.js
// websdk-{version}.min.js.map
gulp.task('sdk:umd:min', ['sdk:umd'], function () {
return gulp.src('./dist/websdk-' + version + '.js')
.pipe(babel({
presets: [es2015]
}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(rename('websdk-' + version + '.min.js'))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'))
})
gulp.task('sdk', ['sdk:umd', 'sdk:umd:min'])
gulp.task('default', ['sdk'])
//
// gulp.task('watch', function() {
// livereload.listen(); //要在这里调用listen()方法
// gulp.watch('less/*.less', ['less']);
// });