-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·73 lines (65 loc) · 2.29 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
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var rename = require('gulp-rename');
var clean = require('gulp-clean');
var livereload = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var imagemin = require('gulp-imagemin');
var uglify = require('gulp-uglify');
var cache = require('gulp-cache');
var notify = require("gulp-notify");
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync');
//Styles task
gulp.task('styles', function(){
return gulp.src('css/*.scss')
.pipe(plumber())
.pipe(sass({style: 'compressed'}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({stream:true}))
.pipe(notify("Styles task completed"));
});
//Scripts task
gulp.task('scripts', function(){
return gulp.src('js/*.js')
.pipe(plumber())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('js/min'))
.pipe(browserSync.reload({stream:true, once: true}))
.pipe(notify("Scripts task completed"));
});
//Image min task
gulp.task('images', function(){
return gulp.src('images/*')
.pipe(plumber())
.pipe(cache(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true })))
.pipe(gulp.dest('images/optimised'))
.pipe(browserSync.reload({stream:true, once: true}))
.pipe(notify("Images task completed"));
});
//Clean out the images directory
gulp.task('clean', function() {
return gulp.src('images/**/*', {read: false})
.pipe(clean())
.pipe(notify("Clean task completed"));
});
//Browser Sync
gulp.task('browser-sync', function() {
browserSync.init(null, {
proxy: "imagersz.dev"
});
});
//Default Task - Run browser sync and watch for changes
gulp.task('default', ['browser-sync'], function () {
// Watch .scss files
gulp.watch('css/*.scss', ['styles']);
// Watch .js files
gulp.watch('js/*.js', ['scripts']);
// Watch images
gulp.watch('images/*', ['images']);
});