-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
63 lines (44 loc) · 1.25 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
"use strict";
var gulp = require('gulp');
var merge = require('merge-stream');
var through = require('through2');
var source = require('vinyl-source-stream');
var del = require('del');
var transform = require('./main').transform;
var JSXX_OPTIONS = {
harmony: true,
sourceMap: false,
stripTypes: true
};
function jsxxify() {
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
// return empty file
cb(null, file);
return;
}
if (file.isStream()) {
return cb(Error('Streaming not supported'));
}
// File is a Buffer if we reach here
file.contents = new Buffer(transform(String(file.contents), JSXX_OPTIONS));
cb(null, file);
});
}
gulp.task('careless', function() {
return gulp.src('src/careless/**/*.js')
.pipe(jsxxify())
.pipe(gulp.dest('dist/careless'));
});
gulp.task('samples', ['careless'], function() {
var ressources = gulp.src('src/samples/**/*.{jpg,png,json,txt,css,md}')
.pipe(gulp.dest('dist/samples'));
var scripts = gulp.src('src/samples/**/*.{js,jsx}')
.pipe(jsxxify())
.pipe(gulp.dest('dist/samples'));
return merge(ressources, scripts);
});
gulp.task('clean', function(cb) {
del(['dist/*'], cb);
});
gulp.task('default', ['careless', 'samples']);