forked from SocketCluster/socketcluster-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (49 loc) · 1.35 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
var gulp = require('gulp');
var path = require('path');
var browserify = require('browserify');
var babel = require('gulp-babel');
var derequire = require('gulp-derequire');
var insert = require('gulp-insert');
var rename = require('gulp-rename');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var convertNewline = require('gulp-convert-newline');
var BUILD = 'browser';
var DIST = './';
var VERSION = require('./package.json').version;
var FULL_HEADER = (
'/**\n' +
' * SocketCluster JavaScript client v' + VERSION + '\n' +
' */\n');
gulp.task('browserify', function() {
var stream = browserify({
builtins: ['_process', 'events', 'buffer', 'querystring'],
entries: 'index.js',
standalone: 'socketCluster'
})
.ignore('_process')
.bundle();
return stream.pipe(source('socketcluster.js'))
.pipe(convertNewline({
newline: 'lf',
encoding: 'utf8'
}))
.pipe(derequire())
.pipe(insert.prepend(FULL_HEADER))
.pipe(gulp.dest(DIST));
});
gulp.task('minify', function() {
return gulp.src(DIST + 'socketcluster.js')
.pipe(babel({
comments: false
}))
.pipe(babel({
plugins: ['minify-dead-code-elimination']
}))
.pipe(uglify())
.pipe(insert.prepend(FULL_HEADER))
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(DIST))
});