-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
104 lines (91 loc) · 2.32 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
var gulp = require('gulp');
var _ = require('lodash');
var connect = require('gulp-connect');
var react = require('gulp-react');
var karma = require('karma').server;
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var karmaCommonConf = {
browsers: ['PhantomJS'],
frameworks: ['jasmine'],
reporters: ['dots'],
files: [
'test/helpers/**/*.js',
'dev/js/lib/react/react-with-addons.js',
'dev/js/pillbox.js',
'test/**/*.spec.js'
]
};
/**
* Run test once and exit
*/
gulp.task('test', ['react-dev', 'react-test', 'copy-dev'], function (done) {
karma.start(_.assign({}, karmaCommonConf, {singleRun: true}), done);
});
/**
* Watch for file changes and re-run tests on each change
*/
gulp.task('tdd', function (done) {
karma.start(karmaCommonConf, done);
});
gulp.task('watch', function(done) {
gulp.watch(['src/**/*', 'test/**/*'], ['react-dev', 'react-test', 'copy-dev-css']);
});
gulp.task('connect', function() {
connect.server({
root: ['dev'],
port: 1337
})
});
/**
* Copy css files to dev
*/
gulp.task('copy-dev-css', function(done) {
return gulp.src('src/css/**/*')
.pipe(gulp.dest('dev/css'));
});
/**
* Copy css files to dist
*/
gulp.task('copy-dist-css', function(done) {
return gulp.src('src/css/**/*')
.pipe(minifyCss())
.pipe(gulp.dest('dist/css'));
});
/**
* Copy react.js to dev
*/
gulp.task('copy-dev-lib', function(done) {
return gulp.src(['bower_components/**/*'])
.pipe(gulp.dest('dev/js/lib'));
});
/**
* Transform JSX files and copy over to dev
*/
gulp.task('react-dev', function(done) {
return gulp.src('src/**/*.jsx')
.pipe(react())
.pipe(gulp.dest('dev'));
});
/**
* Transform JSX spec files
*/
gulp.task('react-test', function(done) {
return gulp.src('test/**/*.jsx')
.pipe(react())
.pipe(gulp.dest('test'));
});
/**
* Transform JSX files and copy over to dist
*/
gulp.task('react-dist', function(done) {
return gulp.src('src/**/*.jsx')
.pipe(react())
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('copy-dev', ['copy-dev-css', 'copy-dev-lib']);
gulp.task('copy-dist', ['copy-dist-css']);
gulp.task('default', ['react-dev', 'copy-dev', 'test']);
gulp.task('dev', ['react-dev', 'copy-dev', 'watch', 'connect', 'tdd']);
gulp.task('dist', ['default', 'react-dist', 'copy-dist']);