-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
69 lines (60 loc) · 1.67 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
// Gulp stuff
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var util = require('gulp-util');
// General Stuff
var del = require('del');
var runSequence = require('run-sequence');
// Browserify stuff (es6)
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
// Config
var dest = 'dist';
// Error handler
var errorHandler = function() {
return plumber({
errorHandler: function(error) {
util.log(util.colors.red('Unhandled error:\n'), error.toString());
return this.emit('end');
}
});
};
/*--------------------------------------
Javascript
--------------------------------------*/
gulp.task('clean:js', function() {
return del(dest);
});
gulp.task('js', ['clean:js'], function() {
return browserify({
entries: [
'src/SocialLinks.js'
],
debug: true
})
.transform(babelify, {
presets: ['env']
})
.bundle()
.pipe(source('SocialLinks.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(errorHandler())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dest));
});
/*--------------------------------------
General gulp tasks
--------------------------------------*/
gulp.task('build', ['js']);
gulp.task('watch', function() {
return gulp.watch('src/**', ['js']);
});
gulp.task('default', function (cb) {
return runSequence('build', 'watch', cb);
});