-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (48 loc) · 1.7 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
const gulp = require('gulp');
const concat = require('gulp-concat-css');
const clean = require('gulp-clean-css');
const rename = require('gulp-rename');
const notifier = require('node-notifier');
/**
* Because there exist a few CSS files we aim to bundle them in to one nice browser import
* Stick everything that ends in .css in src/ together and bung it in dist/
*/
gulp.task('bundle', () => {
return gulp.src('src/*.css')
.pipe(concat('bundle.css'))
.pipe(gulp.dest('dist'));
});
/**
* This library may be used one day in production
* We therefore seek to minify the bundle previously generated
*/
gulp.task('minify', ['bundle'], () => {
return gulp.src('dist/bundle.css')
.pipe(clean({ compatibility: 'ie9' }))
.pipe(rename('bundle.min.css'))
.pipe(gulp.dest('dist'));
});
/**
* Waiting for changes is hard, and keeping a terminal in the foreground is a ballache.
* Shooting a notification on build takes up less screen real-estate
* -- we use gulp to run libnotify
* Because minify is listed as a dependency, we can ensure that we're notified after a build AND minify!
*/
gulp.task('notify', ['minify'], () => {
notifier.notify({
title: 'Gulp',
message: 'Build complete',
});
});
/**
* We may want to test this CSS file in the browser, and make changes accordingly
* To aid this, we keep a watch on everything that we change, so that the browser import stays the same
*/
gulp.task('watch', () => {
gulp.watch('src/*.css', ['notify']);
});
/**
* By default, we don't want to watch this file, because it's gulp is the postinstall command
* So, the user gets one fresh file once they've installed.
*/
gulp.task('default', ['notify']);