This repository has been archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
80 lines (65 loc) · 1.72 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
'use strict';
var gulp = require('gulp');
var minify = require('gulp-minify-css');
var help = require('gulp-task-listing');
var stylus = require('gulp-stylus');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var livereload = require('gulp-livereload');
var options = {
srcFiles: './lib/**/*.styl',
distPath: './dist',
developmentName: 'waffles.css',
productionName: 'waffles.min.css',
readme: './README.md',
gulpfile: './gulpfile.js'
};
function buildDev() {
gulp.src(options.srcFiles)
.pipe(stylus())
.pipe(gulp.dest(options.distPath));
}
function buildProduction() {
gulp.src(options.srcFiles)
.pipe(stylus())
.pipe(minify())
.pipe(rename(function addMin(path) {
path.extname = '.min.css';
}))
.pipe(gulp.dest(options.distPath));
}
function cleanDist() {
gulp.src(options.distPath)
.pipe(rimraf({
force: true
}));
}
function notifyStylusChange() {
gulp.watch(options.srcFiles, livereload.changed);
}
function notifyReadmeChange() {
gulp.watch(options.readme, livereload.changed);
}
function notifyGulpfileChange() {
// Can you handle the meta!?
gulp.watch(options.gulpfile, livereload.changed);
}
function startListener() {
livereload.listen();
}
gulp.task('watch-stylus', notifyStylusChange);
gulp.task('watch-readme', notifyReadmeChange);
gulp.task('watch-gulpfile', notifyGulpfileChange);
gulp.task('watch-startListener', startListener);
gulp.task('watch', [
'watch-stylus',
'watch-readme',
'watch-gulpfile',
'watch-startListener'
]);
gulp.task('build-development', buildDev);
gulp.task('build-production', buildProduction);
gulp.task('build', ['build-development', 'build-production']);
gulp.task('clean', cleanDist);
gulp.task('help', help);
gulp.task('default', ['help']);