forked from Ovilia/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (58 loc) · 1.7 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var jekyll = require('gulp-jekyll');
/**
* Compile files from _style into css
*/
gulp.task('sass', function () {
return gulp.src('_style/general.scss')
.pipe(sass({
includePaths: ['scss'],
onError: function(e) {
console.error(e);
},
outputStyle: 'compressed'
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(rename('default.min.css'))
.pipe(gulp.dest('css'))
.pipe(gulp.dest('_site/css'));
});
/**
* Minify js
*/
gulp.task('compress', function() {
return gulp.src('js/common.js')
.pipe(uglify())
.pipe(rename('common.min.js'))
.pipe(gulp.dest('js'));
});
/**
* Build with Jekyll
*/
gulp.task('jekyll', function () {
return gulp.src(['.'])
.pipe(jekyll({
source: '.',
destination: '_site'
}))
.pipe(gulp.dest('_site'));
});
/**
* Watch scss files for changes & recompile
* Watch html/md files, run jekyll & reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch('_style/*.scss', ['sass']);
gulp.watch('js/common.js', ['compress']);
// gulp.watch(['js/*.js', 'css/*.css'], ['jekyll']);
// gulp.watch(['*.html', '_posts/*', '_layouts/*', '_includes/*'], ['jekyll']);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['compress', 'sass', 'watch']);