-
Notifications
You must be signed in to change notification settings - Fork 219
/
gulpfile.js
81 lines (67 loc) · 2.03 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
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
sass = require('gulp-ruby-sass'),
prefixer = require('gulp-autoprefixer'),
purify = require('gulp-purifycss'),
rename = require('gulp-rename'),
del = require('del'),
runSequence = require('run-sequence');
// Browsersync stuff -> livereloads page after CSS changes
var browserSync = require("browser-sync").create();
browserSync.init({
proxy: "http://127.0.0.1:4000/sinatra.github.com/" // creates a proxy for localhost
});
browserSync.watch("css/**/*.css").on("change", browserSync.reload);
// JS stuff
gulp.task('js', function(){
return gulp.src(['js/*.js', '!js/*.min.js'])
.pipe(uglify())
.pipe(rename({
suffix: '.min'}))
.pipe(gulp.dest('js/min'));
});
// Sass/CSS stuff
gulp.task('watch', function(){
gulp.watch(['_sass/**/*.sass', 'css/development/*.css'], ['build-css']);
});
gulp.task('build-css', function(callback) {
runSequence('sass2css',
'prefix',
'purify',
'clean-css',
callback);
});
gulp.task('sass2css', function(){
console.log("Buidling your CSS from Sass");
return sass('_sass/*.sass')
//return sass('_sass/application.sass', { style: 'compressed' })
.pipe(gulp.dest('css/development/'));
});
gulp.task('prefix', function(){
console.log("Starting autoprefixer");
return gulp.src('css/development/*.css')
.pipe(prefixer({
browsers: [
'> 1%',
'last 4 versions',
'firefox >= 4',
'safari 7',
'safari 8',
'IE 8',
'IE 9',
'IE 10',
'IE 11'
],
cascade: false
}))
.pipe(gulp.dest('css/prefixed'));
});
gulp.task('purify', function() {
console.log("Purifying your CSS from unused styles and minifying it");
return gulp.src(['css/prefixed/*.css'])
.pipe(purify(['_site/*.html'], { minify: true, rejected: true }))
.pipe(gulp.dest('css/'));
});
gulp.task('clean-css', function() {
return del('css/prefixed');
});