forked from rampatra/photography
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (60 loc) · 1.85 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
'use strict';
var gulp = require('gulp');
var imageResize = require('gulp-image-resize');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var del = require('del');
//remove spaces from image file names they cause chaos
gulp.task("underscore", function (done) {
gulp.src("images/*.*")
//.pipe(changed("images/"))
//Remove Space
.pipe(rename(function(opt) {
opt.basename = opt.basename.split(' ').join('_');
return opt;
}))
//Copy to destination
.pipe(gulp.dest("images/renamed_source"));
done();
});
gulp.task('resize', function () {
return gulp.src('images/renamed_source/*.*')
.pipe(imageResize({
width: 1024,
imageMagick: true,
format: "jpg"
}))
.pipe(gulp.dest('images/fulls'))
.pipe(imageResize({
width: 512,
imageMagick: true,
format: "jpg"
}))
.pipe(gulp.dest('images/thumbs'));
});
gulp.task('del', ['resize'], function () {
return del(['images/*.*']);
});
// compile scss to css
gulp.task('sass', function () {
return gulp.src('assets/sass/main.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename({basename: 'main.min'}))
.pipe(gulp.dest('assets/css'));
});
// watch changes in scss files and run sass task
gulp.task('sass:watch', function () {
gulp.watch('assets/sass/**/*.scss', ['sass']);
});
// minify js
gulp.task('minify-js', function () {
return gulp.src('assets/js/main.js')
.pipe(uglify())
.pipe(rename({basename: 'main.min'}))
.pipe(gulp.dest('assets/js'));
});
// default task
gulp.task('default', ['underscore','resize', 'sass', 'minify-js']);
// scss compile task
gulp.task('compile-sass', ['sass', 'minify-js']);