-
Notifications
You must be signed in to change notification settings - Fork 108
/
gulpfile.js
113 lines (95 loc) · 3.1 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'use strict';
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var sass = require('gulp-sass');
var csso = require('gulp-csso');
var livereload = require('gulp-livereload');
var tinylr = require('tiny-lr');
var server = tinylr();
var gutil = require('gulp-util');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var srcDir = 'ui/';
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserifyProtect = require('gulp-browserify-protect');
var PRODUCTION_MODE = gutil.env.production;
gulp.task('js-lib', function() {
return gulp.src(srcDir + 'js/lib/**/*.js')
.pipe(gulpif(PRODUCTION_MODE, uglify()))
.pipe(gulp.dest('./public/js/lib/'))
.pipe( livereload( server ));
});
gulp.task('browserify', function() {
gulp.src(srcDir + 'js/pages/*.js')
.pipe(browserify({
debug: !PRODUCTION_MODE,
external: ['scatter', 'roi']
}))
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(gulpif(PRODUCTION_MODE, uglify()))
.pipe(gulp.dest('./public/js/'))
.pipe( livereload( server ));
return gulp.src(srcDir + 'js/app.js')
.pipe(browserify({
debug : !PRODUCTION_MODE
}))
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(gulpif(PRODUCTION_MODE, uglify()))
.pipe(gulp.dest('./public/js/'))
.pipe( livereload( server ));
});
gulp.task('standalone-js', function() {
var browserify = require('browserify');
var b = browserify({
entries: srcDir + 'js/etc/standalone.js',
debug: false
});
return b.bundle()
.pipe(source('standalone.js'))
.pipe(buffer())
.pipe(browserifyProtect())
.pipe(uglify())
// .on('error', gutil.log)
.pipe(gulp.dest('.'));
});
gulp.task('css', function() {
return gulp
.src(srcDir + 'stylesheets/app.scss')
.pipe(
sass({
includePaths: ['src/stylesheets'],
errLogToConsole: true
}))
.pipe( gulpif(PRODUCTION_MODE, csso()) )
.pipe( gulp.dest('./public/css/') )
.pipe( livereload( server ));
});
gulp.task('fonts', function() {
return gulp
.src(srcDir + 'fonts/**/*.{otf,svg,ttf,woff,eot}')
.pipe( gulp.dest('./public/fonts/') )
.pipe( livereload( server ));
});
gulp.task('images', function() {
return gulp
.src(srcDir + 'images/**/*')
.pipe( gulp.dest('./public/images/') )
.pipe( livereload( server ));
});
gulp.task('watch', function () {
server.listen(35729, function (err) {
if (err) {
return console.log(err);
}
gulp.watch(srcDir + 'stylesheets/**/*.{scss,css}',['css']);
gulp.watch(srcDir + 'js/**/*.js',['js']);
});
});
gulp.task('js', ['browserify','js-lib']);
gulp.task('static', ['js', 'css', 'fonts', 'images']);
gulp.task('default', ['static','watch']);
gulp.task('build', ['static']);
gulp.task('heroku:production', ['static']);