-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
78 lines (67 loc) · 1.81 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
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var jshint = require('gulp-jshint');
var minifycss = require('gulp-minify-css');
var newer = require('gulp-newer');
var notify = require('gulp-notify');
var plumber = require('gulp-plumber');
var reload = browserSync.reload;
var sass = require('gulp-sass');
var onError = function(err) {
notify.onError({
title: "Error",
message: "<%= error %>",
})(err);
this.emit('end');
};
var plumberOptions = {
errorHandler: onError,
};
gulp.task('minifycss', function() {
return gulp.src('assets/css/**/*.css')
.pipe(minifycss())
.pipe(gulp.dest('assets/css'))
});
gulp.task('sass', function() {
var autoprefixerOptions = {
browsers: ['last 2 versions'],
};
var filterOptions = '**/*.css';
var reloadOptions = {
stream: true,
};
var sassOptions = {
includePaths: [
'bower_components/bourbon/app/assets/stylesheets',
'bower_components/mq-sass/stylesheets'
]
};
return gulp.src('assets/sass/**/*.scss')
.pipe(plumber(plumberOptions))
.pipe(sass(sassOptions))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest('assets/css'))
.pipe(filter(filterOptions))
.pipe(reload(reloadOptions));
});
gulp.task('watch', function() {
gulp.watch('assets/sass/**/*.scss', ['sass']);
});
gulp.task('browsersync', function() {
browserSync({
server: {
baseDir: './'
},
open: false,
online: false,
notify: false,
});
});
gulp.task('build', ['sass']);
gulp.task('default', ['sass', 'browsersync', 'watch']);
gulp.task('production', ['build'], function() {
gulp.start('minifycss');
});