-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
58 lines (52 loc) · 1.3 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
//
// Dependencies
//
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var cssnano = require('gulp-cssnano');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
//
// Tasks
//
// Compile SASS
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('css'))
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({
stream: true
}))
});
// Uglify CSS
gulp.task('cssnano', function() {
return gulp.src('css/*.css')
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('css/min'))
.pipe(browserSync.reload({
stream: true
}))
});
// Spin up server and use browser sync
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: ''
},
})
});
// Start watching for development
gulp.task('watch', ['browserSync', 'sass', 'cssnano'], function() {
gulp.watch('scss/**/*.scss', ['sass']);
gulp.watch('css/*.css', ['cssnano']);
gulp.watch('*.html', browserSync.reload);
});
// Runs on 'GULP'
gulp.task('default', function (callback) {
runSequence(['sass', 'cssnano', 'browserSync', 'watch'],
callback
)
});