forked from hmagph/iot-play-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
118 lines (101 loc) · 3.3 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
'use strict';
var gulp = require('gulp'),
less = require('gulp-less'),
path = require('path'),
browserify = require('browserify'),
uglify = require('gulp-uglify'),
htmlreplace = require('gulp-html-replace'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
jshint = require('gulp-jshint'),
install = require("gulp-install"),
//jscs = require('gulp-jscs'),
paths = {
js: ['*.js', '**/*.js', '!**/node_modules/**', '!public/**', '!client/iotphone/**', '!test/ut-coverage/**', '!test/integ-tests-coverage/**', '!test/all-tests-coverage/**', '!test/merged-coverage/**']
};
gulp.task('bower', function() {
return gulp.src(['./bower.json'])
.pipe(install({
allowRoot: true,
args: ['--config.interactive=false']
}));
});
/*
Gulp tasks for linting
*/
gulp.task('lint', function() {
return gulp.src(paths.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
//.pipe(jscs());
});
gulp.task('iotphone', function() {
return gulp.src('client/iotphone/**/*')
.pipe(gulp.dest('public/iotphone'));
});
gulp.task('browserify.prod', function() {
return browserify('./client/app/app.js')
.bundle()
.pipe(source('bundle.min.js'))
.pipe(buffer())
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('./public/js/'));
});
gulp.task('browserify.dev', function() {
return browserify('./client/app/app.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./public/js/'));
});
gulp.task('polymer_components', function() {
return gulp.src('client/app/shared/elements/**/*')
.pipe(gulp.dest('public/app/shared/elements'));
});
gulp.task('less', function() {
return gulp.src('./client/assets/less/*.less')
.pipe(less({ paths: [ path.join(__dirname, 'less', 'includes') ] }))
.pipe(gulp.dest('public/assets/css'));
});
gulp.task('views', function() {
return gulp.src('client/**/*.html')
.pipe(gulp.dest('public/'));
});
gulp.task('images', function() {
return gulp.src('client/assets/img/**/*.*')
.pipe(gulp.dest('public/assets/img'));
});
gulp.task('css', function() {
return gulp.src('client/assets/css/**/*.*')
.pipe(gulp.dest('public/assets/css'));
});
gulp.task('watch', function() {
gulp.watch('./client/app/shared/elements/**/*', ['polymer_components']);
gulp.watch('./client/app/**/*.js', ['browserify.dev']);
gulp.watch('./client/app/**/*.html', ['views']);
gulp.watch('./client/app/**/*.*', ['images']);
gulp.watch('./client/assets/less/*.less', ['less']);
});
gulp.task('prodrun', ['lint', 'iotphone', 'browserify.prod', 'polymer_components', 'views', 'images','less','css'], function() {
gulp.src('./client/play.html')
.pipe(htmlreplace({
'js': 'js/bundle.min.js'
}))
.pipe(gulp.dest('./public'));
});
gulp.task('devrun', ['lint', 'iotphone', 'browserify.dev', 'polymer_components', 'views', 'images','less','css'], function() {
gulp.src('./client/play.html')
.pipe(htmlreplace({
'js': 'js/bundle.js'
}))
.pipe(gulp.dest('./public'));
gulp.start('watch');
});
gulp.task('prod', ['bower'], function() {
gulp.start('prodrun');
});
gulp.task('default', ['bower'], function() {
gulp.start('devrun');
});