-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
133 lines (111 loc) · 3.58 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
133
/*!
* gulp
* $ npm install gulp-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
mainBowerFiles = require('main-bower-files');
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
jasmine = require('gulp-jasmine'),
connect = require('gulp-connect'),
livereload = require('gulp-livereload'),
del = require('del'),
deploy = require('gulp-gh-pages'),
sourcemaps = require('gulp-sourcemaps'),
babel = require('gulp-babel');
gulp.task('fileinclude', function() {
return gulp.src(['src/index.html', 'src/iframe.html', 'src/CNAME', 'src/config.js'])
.pipe(gulp.dest('dist'))
.pipe(notify({ message: 'Index Copied' }));
});
gulp.task('templates', function() {
return gulp.src('src/app/templates/**/*.html')
.pipe(gulp.dest('dist/app/templates'))
.pipe(notify({ message: 'templates copied' }));
});
// 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'))
.pipe(notify({ message: 'Styles task complete' }));
});
// Scripts
gulp.task('scripts', function() {
return gulp.src('src/app/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015']
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/app'))
.pipe(notify({ message: 'Scripts task complete' }));
});
// Images
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(gulp.dest('dist/images'))
.pipe(notify({ message: 'Images task complete' }));
});
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'))
.pipe(notify({ message: 'lib copied' }));
});
// Default task
gulp.task('default', ['clean'], function() {
gulp.start('fileinclude', 'styles', 'scripts', 'images', 'templates', 'copy-lib');
});
gulp.task('connect', function() {
connect.server({
root: 'dist',
port: process.env.PORT || 8080,
livereload: false
});
});
gulp.task("heroku:production", function(){
gulp.start('connect')
});
// Watch
gulp.task('watch', function() {
gulp.start('default')
// Create LiveReload server
livereload.listen({start:true});
// Watch .html files
gulp.watch('src/**/*.html', ['fileinclude', 'templates']);
gulp.watch('src/app/templates/**/*.html', ['templates']);
// Watch .scss files
gulp.watch(['src/styles/**/*.scss', 'src/lib/**/*.css'], ['styles']);
// Watch .js files
gulp.watch('src/app/**/*.js', ['scripts']);
// Watch image files
gulp.watch('src/images/**/*', ['images']);
// 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());
});