forked from flux3dp/flux-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (86 loc) · 2.65 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
webserver = require('gulp-webserver'),
exec = require('gulp-exec'),
react = require('gulp-react'),
uglify = require('gulp-uglify'),
pump = require('pump'),
babel = require('gulp-babel'),
sourcemaps = require('gulp-sourcemaps'),
cleanCSS = require('gulp-clean-css'),
mocha = require('gulp-mocha');
gulp.task('deployment', ['babel', 'cleancss'], function(cb) {
pump([
gulp.src(['public/js/**/*.js', '!public/js/require.js', '!public/js/main.js']),
sourcemaps.init(),
uglify(),
sourcemaps.write(),
gulp.dest('public/js/')
],
cb
);
});
gulp.task('cleancss', function() {
return gulp.src('public/css/**/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('public/css/'));
});
gulp.task('babel', function() {
return gulp.src(['public/js/**/*.js*', '!public/js/require.js', '!public/js/main.js', '!public/js/plugins/**/*.js', '!public/js/lib/**/*.js', '!public/js/helpers/CircularGridHelper.js'])
.pipe(babel({
presets: ['es2015','react']
}))
.pipe(gulp.dest('public/js'));
});
gulp.task('sass', function () {
gulp.src('./public/sass/**/*.scss')
.pipe(sass({
indentWidth: 4
}).on('error', sass.logError))
.pipe(gulp.dest('./public/css/'));
});
gulp.task('jsx', function () {
gulp.src('./public/js/**/*.jsx')
.pipe(react())
.pipe(gulp.dest('./public/js/jsx/'));
});
gulp.task('sass:watch', function () {
gulp.watch('./public/sass/**/*.scss', ['sass']);
});
gulp.task('jsx:watch', function () {
gulp.watch('./public/js/**/*.jsx', ['jsx']);
});
gulp.task('electron', function() {
gulp.watch('./src/*', ['jsx']);
});
gulp.task('webserver', ['sass:watch'], function() {
gulp.src('public')
.pipe(webserver({
livereload: true,
open: false,
host: '0.0.0.0',
port: 8111
}));
});
gulp.task('dev', ['sass:watch', 'jsx:watch', 'jsx', 'sass', 'electron', 'webserver']);
gulp.task('unit-test', function() {
return gulp.
src('./_test/unit/**/*.js', { read: false }).
pipe(mocha({
require: [
process.cwd() + '/_test/unit/bootstrap.js'
]
})).
once('error', function() {
process.exit(1); // bad happens
}).
once('end', function() {
process.exit(); // good
});
});
gulp.task('api-test', function() {
return gulp.
src('./_test/api/**/*.js').
pipe(exec('node <%= file.path %>')).
pipe(exec.reporter());
});