forked from unconed/shadergraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
128 lines (106 loc) · 2.54 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var rename = require("gulp-rename");
var runSequence = require('run-sequence');
var browserify = require('gulp-browserify');
var watch = require('gulp-watch');
var KarmaServer = require('karma').Server;
var builds = {
core: 'build/shadergraph-core.js',
bundle: 'build/shadergraph.js',
css: 'build/shadergraph.css',
};
var products = [
builds.core,
builds.bundle,
];
var vendor = [
];
var css = [
'src/**/*.css',
];
var core = [
'.tmp/index.js'
];
var coffees = [
'src/**/*.coffee',
]
var bundle = vendor.concat(core);
var test = [
'node_modules/three/three.js',
].concat(bundle).concat([
'test/**/*.spec.coffee',
]);
gulp.task('browserify', function () {
return gulp.src('src/index.coffee', { read: false })
.pipe(browserify({
debug: false,
//detectGlobals: false,
//bare: true,
transform: ['coffeeify'],
extensions: ['.coffee'],
}))
.pipe(rename({
extname: ".js"
}))
.pipe(gulp.dest('.tmp/'))
});
gulp.task('css', function () {
return gulp.src(css)
.pipe(concat(builds.css))
.pipe(gulp.dest(''));
});
gulp.task('core', function () {
return gulp.src(core)
.pipe(concat(builds.core))
.pipe(gulp.dest(''));
});
gulp.task('bundle', function () {
return gulp.src(bundle)
.pipe(concat(builds.bundle))
.pipe(gulp.dest(''));
});
gulp.task('uglify', function () {
return gulp.src(products)
.pipe(uglify())
.pipe(rename({
extname: ".min.js"
}))
.pipe(gulp.dest('build'));
});
gulp.task('karma', function (done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
files: test,
singleRun: true,
}, done).start();
});
gulp.task('watch-karma', function() {
return gulp.src(test)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'watch',
}));
});
gulp.task('watch-build-watch', function () {
watch(coffees.concat(css), function () {
return gulp.start('build');
});
});
// Main tasks
gulp.task('build', function (callback) {
runSequence('browserify', ['css', 'core', 'bundle'], callback);
})
gulp.task('default', function (callback) {
runSequence('build', 'uglify', callback);
});
gulp.task('test', function (callback) {
runSequence('build', 'karma', callback);
});
gulp.task('watch-build', function (callback) {
runSequence('build', 'watch-build-watch', callback);
})
gulp.task('watch', function (callback) {
runSequence('watch-build', 'watch-karma', callback);
});