This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
forked from mattmischuk/trianglify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (60 loc) · 1.92 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 fs = require('fs');
var path = require('path');
var browserify = require('browserify');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var notifier = require('node-notifier');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var buffer = require('vinyl-buffer');
var production = process.env.NODE_ENV == 'production';
// Spin up a browserify instance
var bundler = browserify('./lib/trianglify.js', {
standalone: 'Trianglify',
cache: {},
packageCache: {},
fullPaths: true
});
bundler.exclude('crypto');
gulp.task('browserify', ['jshint'], function() {
// start the deps bundler
return bundler.bundle()
.on('error', function(error) {
notifier.notify({
'title': 'Browserify Build Failed',
'message': path.relative(__dirname, error.filename)
});
console.log(error.message);
this.emit('end');
})
.pipe(source('./trianglify.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('browser-test', ['jshint'], function() {
var testBundler = browserify('./test/test.js', {
standalone: 'Trianglify',
cache: {},
packageCache: {},
fullPaths: true
});
return testBundler.bundle()
.pipe(source('test.browserify.js'))
.pipe(gulp.dest('test'));
});
// Check source for syntax errors and style issues
// TODO notifications. Probably need to look into switching to gulp-notify
gulp.task('jshint', function() {
return gulp.src(['lib/**/*.js', 'test/**/*.js', '!test/test.browserify.js', 'gulpfile.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('watch', ['browserify'], function() {
gulp.watch('lib/**/*.js', ['browserify']);
});
gulp.task('clean', function(done) {fs.unlink('dist', done);});
gulp.task('default', ['browserify']);