-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
74 lines (67 loc) · 2.08 KB
/
gulpfile.js
File metadata and controls
74 lines (67 loc) · 2.08 KB
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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
del = require('del'),
browserSync = require('browser-sync').create();
gulp.task('scripts', function () {
return gulp.src(['app/**/*.js', '!app/build/**/*.js'])
.pipe(concat('cloudplayer-v0.1.0.js'))
.pipe(gulp.dest('build/app/javascript'))
.pipe(rename({
suffix: '.min'
}))
.pipe(uglify())
.pipe(gulp.dest('build/app/javascript'))
.pipe(notify({
message: 'Scripts task complete'
}));
});
gulp.task('images', function () {
return gulp.src('assets/images/**/*')
.pipe(imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
}))
.pipe(gulp.dest('build/assets/images'))
.pipe(notify({
message: 'Images task complete' //Will notifiy each image minification
}));
});
gulp.task('clean', function (cb) {
del(['build/assets/css', 'build/app/javascript', 'build/assets/images'], cb)
});
gulp.task('default', ['clean'], function () {
gulp.start('scripts', 'images', 'serve', 'watch');
});
gulp.task('watch', function () {
// Watch .scss files
// gulp.watch('assets/styles/**/*.css', ['styles']);
// Watch .js files
gulp.watch(['app/**/*.js', '!app/build/**/*.js'], ['scripts']);
// Watch image files
gulp.watch('assets/images/**/*', ['images']);
gulp.watch(['index.html', 'build/app/**/*.js', 'app/**/*.html']).on('change', browserSync.reload);
});
gulp.task('serve', function(){
if (browserSync.active){
return;
};
browserSync.init({
injectChanges: true,
server: ['./','build/app/**/*.*', 'app/**/*.html'],
ghostMode: {
clicks:true,
location: false,
forms: true,
scroll:true,
},
notify: true,
reloadDelay: 1000
})
});