-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
123 lines (101 loc) · 3.19 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
// Load plugins
var gulp = require('gulp'),
mainBowerFiles = require('main-bower-files');
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
eslint = require('gulp-eslint'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
jasmine = require('gulp-jasmine'),
connect = require('gulp-connect'),
livereload = require('gulp-livereload'),
del = require('del'),
deploy = require('gulp-gh-pages'),
babel = require('gulp-babel');
gulp.task('fileinclude', function() {
return gulp.src(['src/index.html', 'src/iframe.html'])
.pipe(gulp.dest('dist'));
});
gulp.task('templates', function() {
return gulp.src('src/app/templates/**/*.html')
.pipe(gulp.dest('dist/app/templates'));
});
// Styles
gulp.task('styles', function() {
return gulp.src('src/styles/**/*.scss')
.pipe(sass({includePaths: require('node-neat').includePaths}).on('error', sass.logError))
.pipe(autoprefixer('last 2 version'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/styles'));
});
// Scripts
gulp.task('scripts', function() {
return gulp.src('src/app/**/*.js')
.pipe(eslint('./.eslintrc'))
.pipe(eslint.format())
.pipe(babel())
.pipe(gulp.dest('dist/app'));
});
// Cities Config
gulp.task('cities_config', function() {
return gulp.src('src/cities/*.json')
.pipe(eslint('./.eslintrc'))
.pipe(eslint.format())
.pipe(gulp.dest('dist/cities'));
});
// Images
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(gulp.dest('dist/images'));
});
gulp.task('copy-bower', function() {
return gulp.src(mainBowerFiles())
.pipe(gulp.dest('dist/app/lib'));
});
// Clean
gulp.task('clean', function(cb) {
del(['dist/assets/css', 'dist/assets/js', 'dist/assets/img'], cb)
});
gulp.task('copy-lib', function() {
return gulp.src('src/lib/**/*')
.pipe(gulp.dest('dist/lib'));
});
// Default task
gulp.task('default', gulp.series('clean', 'fileinclude', 'styles', 'scripts', 'images', 'templates', 'cities_config', 'copy-lib'));
gulp.task('connect', function() {
connect.server({
host: '0.0.0.0',
root: 'dist',
port: process.env.PORT || 8080,
livereload: false
});
});
gulp.task("heroku:production", function(){
gulp.series('connect')
});
// Watch
gulp.task('watch', function() {
gulp.task('default')();
// Create LiveReload server
livereload.listen({start:true});
// Watch .html files
gulp.watch('src/**/*.html', gulp.series('fileinclude', 'templates'));
gulp.watch('src/app/templates/**/*.html', gulp.series('templates'));
// Watch .scss files
gulp.watch(['src/styles/**/*.scss', 'src/lib/**/*.css'], gulp.series('styles'));
// Watch .js files
gulp.watch('src/app/**/*.js', gulp.series('scripts'));
// Watch image files
gulp.watch('src/images/**/*', gulp.series('images'));
gulp.watch('src/cities/*.json', gulp.series('cities_config'));
// Watch any files in dist/, reload on change
gulp.watch(['dist/**']).on('change', livereload.changed);
});
gulp.task('deploy', function () {
return gulp.src("./dist/**/*")
.pipe(deploy())
});
gulp.task('test', function () {
return gulp.src('spec/**/*_spec.js')
.pipe(jasmine());
});