-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
95 lines (78 loc) · 2.59 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 params = $.util.env;
var config = {
src: {
base: 'src',
scripts: 'src/scripts',
styles: 'src/styles'
},
dist: {
base: 'dist',
},
demo: {
base: 'dist/demo',
scripts: 'dist/demo/scripts',
styles: 'dist/demo/styles'
},
autoprefixer: ['last 2 versions', 'Explorer >= 8', 'Firefox >= 25']
};
gulp.task('styles', function () {
var filter = $.filter(['initialize.*']);
return sassProcess(config.src.styles + '/*.scss')
.pipe($.plumber())
.pipe($.autoprefixer(config.autoprefixer))
.pipe(gulp.dest(config.demo.styles))
.pipe(filter)
.pipe(gulp.dest(config.dist.base))
.pipe($.cssmin())
.pipe($.rename({suffix: '.min'}))
.pipe(gulp.dest(config.dist.base))
.pipe($.size({title: 'styles'}));
});
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('copy', function () {
return gulp.src(config.src.styles + '/initialize.*')
.pipe($.if('initialize.scss', $.rename({basename: '_initialize'})))
.pipe(gulp.dest(config.dist.base))
.pipe($.size({title: 'copy'}));
});
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({
server: {
baseDir: './' + config.demo.base
}
});
gulp.watch([config.src.images + '/**/*'], ['images']);
gulp.watch([config.src.styles + '/**/*.scss'], ['styles']);
gulp.watch([config.src.scripts + '/**/*.js'], ['scripts']);
gulp.watch([config.src.base + '/**/*.html'], ['html']);
browserSync.watch([config.demo.base + '/**/*', config.dist.base + '/**/*']).on('change', browserSync.reload);
});
gulp.task('build', ['styles', 'html', 'copy']);
gulp.task('deploy', ['build'], function() {
params.message = params.m || params.message;
var options = {};
options.message = params.message || 'Update ' + new Date();
return gulp.src(config.demo.base + '/**/*')
.pipe($.ghPages(options));
});
gulp.task('default', ['build']);