-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
94 lines (85 loc) · 2.83 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
del = require('del'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
plumber = require('gulp-plumber'),
browserSync = require('browser-sync'),
cssshrink = require('gulp-cssshrink'),
cp = require('child_process'),
changed = require('gulp-changed'),
imagemin = require('gulp-imagemin'),
size = require('gulp-size'),
ghPages = require('gulp-gh-pages');
gulp.task('styles', function() {
gulp.src('./src/sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('public/stylesheets'))
.pipe(rename({suffix: '.min'}))
//.pipe(minifycss())
//.pipe(cssshrink())
.pipe(gulp.dest('public/stylesheets'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('scripts', function() {
return gulp.src(['./src/javascripts/**/*.js'])
//.pipe(jshint('.jshintrc'))
//.pipe(jshint.reporter('default'))
.pipe(plumber())
.pipe(concat('app.js'))
.pipe(gulp.dest('public/javascripts'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts'))
.pipe(browserSync.reload({stream:true}));
});
// Optimizes the images that exists
gulp.task('images', function () {
return gulp.src('src/images/**')
.pipe(changed('public/images'))
.pipe(imagemin({
// Lossless conversion to progressive JPGs
progressive: true,
// Interlace GIFs for progressive rendering
interlaced: true
}))
.pipe(gulp.dest('public/images'))
.pipe(size({title: 'images'}));
});
gulp.task('html', function() {
gulp.src('./src/**/*.html')
.pipe(gulp.dest('public/'))
});
gulp.task('browser-sync', ['styles', 'scripts'], function() {
browserSync({
server: {
baseDir: "./public/",
injectChanges: true // this is new
}
});
});
gulp.task('deploy', function() {
return gulp.src('./public/**/*')
.pipe(ghPages());
});
gulp.task('watch', function() {
// Watch .html files
gulp.watch('src/**/*.html', ['html', browserSync.reload]);
gulp.watch("public/*.html").on('change', browserSync.reload);
// Watch .sass files
gulp.watch('src/sass/**/*.scss', ['styles', browserSync.reload]);
// Watch .js files
gulp.watch('src/javascripts/*.js', ['scripts', browserSync.reload]);
// Watch image files
gulp.watch('src/images/**/*', ['images', browserSync.reload]);
});
gulp.task('default', function() {
gulp.start('styles', 'scripts', 'images', 'html', 'browser-sync', 'watch');
});