/
gulpfile.js
125 lines (112 loc) · 3.67 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
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var minify = require('gulp-minify-css');
var gulpBabel = require('gulp-babel');
var plumber = require('gulp-plumber');
var mocha = require('gulp-mocha');
var babel = require('babel-core/register');
js_files = [
'./static/javascripts/db.js',
'./static/javascripts/components/notTesting.jsx',
'./static/javascripts/components/questions.jsx',
'./static/javascripts/components/cards.jsx',
'./static/javascripts/components/dashboard.jsx',
'./static/javascripts/components/welcome.jsx',
'./static/javascripts/components/survey_card.jsx',
'./static/javascripts/components/survey_sample.jsx',
'./static/javascripts/components/footer.jsx',
'./static/javascripts/components/profile.jsx',
'./static/javascripts/components/profile_groups.jsx',
'./static/javascripts/components/groups_page.jsx',
'./static/javascripts/components/search_card.jsx',
'./static/javascripts/components/response.jsx',
'./static/javascripts/components/help.jsx'
]
test_js_files_1 = [
'./static/javascripts/db.js',
'./static/javascripts/components/questions.jsx',
'./static/javascripts/components/cards.jsx',
'./static/javascripts/components/dashboard.jsx',
'./static/javascripts/components/welcome.jsx',
'./static/javascripts/components/survey_card.jsx',
'./static/javascripts/components/survey_sample.jsx',
'./static/javascripts/components/footer.jsx',
'./static/javascripts/components/profile.jsx',
'./static/javascripts/components/profile_groups.jsx',
'./static/javascripts/components/groups_page.jsx',
'./static/javascripts/components/search_card.jsx',
'./static/javascripts/components/response.jsx',
'./static/javascripts/components/help.jsx'
]
test_js_files_2 = [
'./static/javascripts/tests/test_requires.js',
'./static/dist/all.js',
'./static/javascripts/tests/test-content.js'
]
// Lint Task
gulp.task('lint', function() {
return gulp.src(js_files)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('dev-js', function() {
//these need to be sequential to prevent
return gulp.src(js_files)
.pipe(plumber({
errorHandler: function(err) {
console.log(err);
this.emit('end');
}
}))
.pipe(gulpBabel())
.pipe(concat('all.js'))
.pipe(rename('all.js'))
.pipe(gulp.dest('./static/dist/'));
});
gulp.task('prod-js', function(){
return gulp.src(js_files)
.pipe(gulpBabel())
.pipe(concat('all.js'))
.pipe(gulp.dest('./static/dist/'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./static/dist/'));
})
gulp.task('minify-css', function () {
gulp.src('./static/stylesheets/*.css')
.pipe(minify({keepBreaks: true}))
.pipe(rename({
suffix: '.min.css'
}))
.pipe(gulp.dest('./static/dist/'));
});
gulp.task('test-compile-1',function(cb) {
return gulp.src(test_js_files_1)
.pipe(gulpBabel())
.pipe(concat('all.js'))
.pipe(gulp.dest('./static/dist/'))
cb();
})
gulp.task('test-compile-2', ['test-compile-1'], function(cb) {
return gulp.src(test_js_files_2)
.pipe(concat('test.js'))
.pipe(gulp.dest('./test/'));
cb();
})
gulp.task('test-run', ['test-compile-2'], function () {
gulp.src('./test/test.js')
.pipe(mocha({
reporter: 'spec',
compilers: {
js:babel
}
}))
});
// Default Task
gulp.task('default', ['scripts', 'minify-css']);