-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
50 lines (44 loc) · 1.36 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
'use strict';
// var options = require('./package');
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var gutil = require('gulp-util');
var rename = require('gulp-rename');
var mocha = require('gulp-mocha');
var babel = require('gulp-babel');
gulp.task('build', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: 'src/main.js',
debug: true
}).transform('babelify', { presets: ['es2015'] });
return b.bundle()
.pipe(source('unrest.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(gulp.dest('./dist/'))
.pipe(rename({extname: '.min.js'}))
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('node', function () {
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist/node'));
});
gulp.task('test', ['node'], function () {
return gulp.src('test/tests.js', {read: false})
.pipe(mocha({reporter: 'spec'}));
});
gulp.task('default', function () {
gulp.watch('src/**/*.js', ['build']);
});