forked from wongjohn/for-my-love
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
67 lines (60 loc) · 1.69 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
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 jade = require('gulp-jade');
var babel = require('gulp-babel');
var minify = require('gulp-minify');
var browserSync = require('browser-sync').create();
/**
* Compile files from _style into css
*/
gulp.task('sass', function () {
return gulp.src('css/main.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('main.min.css'))
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
/**
* compile es6
*/
gulp.task('babel', function () {
gulp.src('src/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(minify())
.pipe(gulp.dest('js'));
});
/**
* Watch scss files for changes & recompile
* Watch html/md files, run jekyll & reload BrowserSync
*/
gulp.task('watch', ['sass', 'babel'], function () {
gulp.watch('css/*.scss', ['sass'])
.on('change', browserSync.reload);
gulp.watch('src/*.js', ['babel'])
.on('change', browserSync.reload);
});
/**
* sync with browser
*/
gulp.task('browser-sync', function() {
browserSync.init({
server: '.'
});
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['watch', 'browser-sync']);