-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
95 lines (81 loc) · 2.42 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var rimraf = require('rimraf');
var browserSync = require('browser-sync');
var merge = require('merge-stream');
var params = $.util.env;
var config = {
src: {
base: 'src',
styles: 'src/styles'
},
dist: {
base: 'dist'
},
demo: {
base: 'dist/demo',
scripts: 'dist/demo/scripts',
styles: 'dist/demo/styles'
},
autoprefixer: [
'last 2 versions',
'Explorer >= 10',
'Firefox >= 25',
'Safari >= 6'
]
};
gulp.task('styles', function() {
var demo = sassProcess(config.src.styles + '/**/*.scss')
.pipe($.plumber())
.pipe(gulp.dest(config.demo.styles));
var grid = sassProcess(config.src.styles + '/the-flex-grid.scss')
.pipe($.plumber())
.pipe(gulp.dest(config.dist.base))
.pipe($.cssmin())
.pipe($.rename({ suffix: '.min' }))
.pipe(gulp.dest(config.dist.base));
var grid_prefixed = sassProcess(config.src.styles + '/the-flex-grid.scss')
.pipe($.plumber())
.pipe($.autoprefixer(config.autoprefixer))
.pipe($.rename({ suffix: '.prefixed' }))
.pipe(gulp.dest(config.dist.base))
.pipe($.cssmin())
.pipe($.rename({ suffix: '.min' }))
.pipe(gulp.dest(config.dist.base))
.pipe($.size({ title: 'styles' }));
return merge(demo, grid, grid_prefixed);
});
function sassProcess(path) {
return gulp.src(path).pipe(
$.sass({
precision: 10,
outputStyle: params.production ? 'compressed' : 'expanded',
includePaths: ['node_modules']
}).on('error', $.sass.logError)
);
}
gulp.task('html', function() {
return gulp
.src([config.src.base + '/**/*.html'])
.pipe(gulp.dest(config.demo.base))
.pipe($.size({ title: 'html' }));
});
gulp.task('clean', function(cb) {
rimraf(config.dist.base, cb);
});
gulp.task('watch', ['build'], function() {
browserSync.init({
reloadDelay: 100,
server: {
baseDir: './' + config.demo.base
}
});
gulp.watch([config.src.styles + '/**/*.scss'], ['styles']);
gulp.watch([config.src.base + '/**/*.html'], ['html']);
browserSync
.watch(config.demo.base + '/**/*')
.on('change', browserSync.reload);
});
gulp.task('build', ['styles', 'html']);
gulp.task('default', ['build']);