-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
70 lines (61 loc) · 1.72 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
58
59
60
61
62
63
64
65
66
67
68
69
70
var gulp = require('gulp');
var template = require('gulp-template');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var size = require('gulp-size');
var notify = require('gulp-notify');
var rename = require('gulp-rename');
var connect = require('gulp-connect');
var throttle = require('gulp-throttle');
var src = 'src/jsRequest.js';
var dist = 'dist';
var templateParams = {
version: require('./package.json').version
};
var notifyParams = {
onLast: true,
message: function (file) {
return file.relative + ' file size: ' + file.stat.size + ' bytes';
}
};
var renameParams = { suffix: '.min' };
gulp.task('build', function () {
return gulp.src(src)
.pipe(template(templateParams))
.pipe(gulp.dest(dist))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(uglify())
.pipe(size())
.pipe(notify(notifyParams))
.pipe(rename(renameParams))
.pipe(gulp.dest(dist));
});
gulp.task('uglify', function () {
return gulp.src(src)
.pipe(template(templateParams))
.pipe(gulp.dest(dist))
.pipe(uglify())
.on('error', notify.onError('Error: <%= error.message %>'))
.pipe(size())
.pipe(notify(notifyParams))
.pipe(rename(renameParams))
.pipe(gulp.dest(dist));
});
gulp.task('default', ['uglify'], function () {
gulp.watch(src, ['uglify']);
var port = 9000;
connect.server({
root: [__dirname],
port: port,
livereload: true
});
throttle({
local_port: port + 1,
remote_port: port,
upstream: 1024 * 10,
downstream: 1024 * 100,
keep_alive: true
});
});