-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
45 lines (39 loc) · 1.34 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
var gulp = require('gulp');
var browserify = require('browserify');
var gutil = require('gulp-util');
var streamify = require('gulp-streamify')
var clean = require('gulp-clean');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var pkg = require('./package.json');
var target = './build/';
gulp.task('default', ['browserify'], function () {
gulp.watch(['./src/*.js', 'test/main_test.js'], ['browserify']);
});
gulp.task('browserify', function () {
var b = browserify('./' + pkg.main);
b.bundle({debug: true, standalone: pkg.name})
.on('error', gutil.log)
.pipe(source(pkg.name + '.js'))
.pipe(gulp.dest(target));
var t = browserify('./test/main_test.js');
t.bundle({debug: true})
.on('error', gutil.log)
.pipe(source('tests.js'))
.pipe(gulp.dest(target));
});
gulp.task('clean', function () {
gulp.src(target, {read: false}).pipe(clean());
});
gulp.task('build', ['clean'], function () {
var b = browserify('./' + pkg.main);
b.bundle({standalone: pkg.name})
.on('error', gutil.log)
.pipe(source(pkg.name + '.js'))
.pipe(gulp.dest(target))
.pipe(streamify(uglify()))
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(target))
});