-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
106 lines (89 loc) · 2.71 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
'use strict';
// Gulp
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var del = require('del');
var fs = require('fs');
var gulp = require('gulp');
var jade = require('gulp-jade');
var sass = require('gulp-sass');
var uglify = require('gulp-uglifyjs');
gulp.task('clean', (function () {
var cleaned = false;
return function (cb) {
if (cleaned) {
cb();
} else {
cleaned = true;
del(['build/**/*'], cb);
}
}
})());
gulp.task('html', function () {
var presets = {};
fs.readdirSync('src/presets').forEach(function (file) {
presets[file] = fs.readFileSync('src/presets/'+ file);
});
gulp.src([
'src/chrome-exp.png',
'src/favicon.ico'
]).pipe(gulp.dest('build'));
gulp.src('src/index.jade')
.pipe(jade({
locals: {
presets: presets,
welcome: fs.readFileSync('src/welcome.txt'),
current: 'scales.js'
}
}))
.pipe(gulp.dest('build'))
});
gulp.task('sass', ['html'], function () {
gulp.src('src/scss/*.scss')
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(gulp.dest('build'));
});
gulp.task('build', ['sass'], function () {
// Copy worker helpers
gulp.src(['src/js/helpers.js']).pipe(uglify()).pipe(gulp.dest('build'))
return gulp.src([
'src/js/renderer.js',
'src/js/shader.js',
'src/js/app.js'
])
.pipe(uglify('app.js'))
.pipe(gulp.dest('build'))
});
gulp.task('vendor', function () {
gulp.src([
'bower_components/jquery/dist/jquery.js',
'bower_components/lodash/dist/lodash.js',
'bower_components/dat-gui/build/dat.gui.js',
'bower_components/catiline/dist/catiline.js',
'bower_components/ace-builds/src-noconflict/ace.js',
'bower_components/ace-builds/src-noconflict/mode-javascript.js',
'bower_components/ace-builds/src-noconflict/theme-solarized_light.js',
])
.pipe(uglify('vendors.js'))
.pipe(gulp.dest('build'))
gulp.src(['bower_components/ace-builds/src-noconflict/worker-javascript.js'])
.pipe(uglify('worker-javascript.js'))
.pipe(gulp.dest('build'))
});
gulp.task('deploy', ['clean', 'build', 'vendor'], function () {
});
gulp.task('reload', ['build'], function () {
browserSync.reload();
});
gulp.task('serve', function () {
browserSync({
notify: false,
server: {
baseDir: 'build'
}
});
});
gulp.task('watch', function () {
gulp.watch(['src/**/*'], ['reload']);
});
gulp.task('default', ['clean', 'build', 'vendor', 'serve', 'watch']);