-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
132 lines (119 loc) · 3.02 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
129
130
131
132
var Promise = require('bluebird');
var gulp = require('gulp');
var del = require('del');
var run = require('gulp-run');
var browserify = require('browserify');
var jshint = require('gulp-jshint');
var jsxcs = require('gulp-jsxcs');
var browserSync = require('browser-sync');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var reactify = require('reactify');
var karma = require('gulp-karma');
var package = require('./package.json');
/**
* Running Bower
*/
gulp.task('bower', function() {
return new Promise(function(resolve, reject) {
run('bower install').exec(function(err) {
if (err) {
return reject(err);
}
resolve(); // finished task
});
});
});
/**
* Cleaning dist/ folder
*/
gulp.task('clean', function() {
return new Promise(function(resolve, reject) {
del(['build/**'], function(err) {
if (err) {
return reject(err);
}
resolve();
});
})
});
gulp.task('copy-assets', function() {
return gulp.src('./bower_components/bootstrap/dist/**', {base: './bower_components/bootstrap/dist'})
.pipe(gulp.dest('./build/assets/bootstrap'));
});
gulp.task('html', function() {
return gulp.src('./app/**/*.html', {base: './app'})
.pipe(gulp.dest('./build'));
});
/**
* Running livereload server
*/
gulp.task('server', function() {
browserSync({
server: {
baseDir: './build'
}
});
});
/**
* JSLint/JSHint validation
*/
gulp.task('lint', function() {
return gulp.src(package.paths.js)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('jsxcs', function() {
return gulp.src(package.paths.js)
.pipe(jsxcs('./.jscsrc'));
});
/** JavaScript compilation */
gulp.task('js', function() {
return browserify(package.paths.app)
.transform(reactify)
.bundle()
.pipe(source(package.dest.app))
.pipe(gulp.dest(package.dest.dist));
});
gulp.task('js:min', function() {
return browserify(package.paths.app)
.transform(reactify)
.bundle()
.pipe(source(package.dest.app))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(package.dest.dist));
});
/**
* Compiling resources and serving application
*/
gulp.task('serve', ['copy-assets', 'js', 'html', 'server'], function() {
return gulp.watch([
'./app/**/*.html', './app/**/*.js'
], [
'js', 'html', browserSync.reload
]);
});
//
//gulp.task('serve:minified', ['bower', 'clean', 'lint', 'less:min', 'js:min', 'server'], function() {
// return gulp.watch([
// package.paths.js, package.paths.jsx, package.paths.html, package.paths.less
// ], [
// 'lint', 'less:min', 'js:min', browserSync.reload
// ]);
//});
var testFiles = [
'test/spec/**/.js'
];
gulp.task('test', function() {
return gulp.src(testFiles)
.pipe(karma({
configFile: 'test/karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
throw err;
});
});
gulp.task('deploy', ['clean', 'copy-assets']);