-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
76 lines (67 loc) · 2.11 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
'use strict';
var gulp = require('gulp');
var express = require('express');
var livereload = require('gulp-livereload');
var browserify = require('gulp-browserify');
var embedlr = require('gulp-embedlr');
var concat = require('gulp-concat-sourcemap');
var lrserver = livereload();
var debug = process.env.NODE_ENV || 'development';
var EXPRESS_PORT = 4000;
var EXPRESS_ROOT = __dirname;
/**
* Embeds live reload snippets on html files in static
*/
function embedLrSnippet() {
if (debug === 'development') {
gulp.src('./static/html/*.html')
.pipe(embedlr())
.pipe(gulp.dest('./static/'));
}
}
/**
* Start the Express server.
*/
function startExpress() {
var app = express();
app.use(express.static(EXPRESS_ROOT + '/static'));
app.use('/bower_components', express.static(EXPRESS_ROOT + '/bower_components'));
app.use('/', express.static(EXPRESS_ROOT + '/static/build/index.html'));
app.listen(EXPRESS_PORT);
}
gulp.task('default', ['libs', 'scripts'], function() {
embedLrSnippet();
startExpress();
gulp.watch('js/**', ['scripts']);
gulp.watch('./static/build/**').on('change', function (file) {
lrserver.changed(file.path);
});
});
gulp.task('scripts', function() {
gulp.src('./js/GridNodes/gridnodes.js')
.pipe(browserify({
insertGlobals: true,
debug: (debug === 'development')
}))
.pipe(gulp.dest('./static/build/'));
gulp.src('./js/Particles/particles.js')
.pipe(browserify({
insertGlobals: true,
debug: (debug === 'development')
}))
.pipe(gulp.dest('./static/build/'));
});
/**
* Build vendor libraries and generate source maps.
* Allows browserify-shim to reference libs as in package.json.
*/
gulp.task('libs', function() {
gulp.src([
'./bower_components/pixi/bin/pixi.js',
'./bower_components/async/lib/async.js',
'./bower_components/underscore/underscore.js',
'./bower_components/dat.gui/dat.gui.js'
])
.pipe(concat('libs.js'))
.pipe(gulp.dest('./static/build'));
});