forked from callmecavs/layzr.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.44 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var notifier = require('node-notifier');
// header for top of dist files
var packageJSON = require('./package.json');
var banner = [
'/*!',
' * Layzr.js <%= pkg.version %> - <%= pkg.description %>',
' * Copyright (c) 2015 <%= pkg.author %> - http://callmecavs.github.io/layzr.js/',
' * License: <%= pkg.license %>',
' */',
'',
''].join('\n');
// error handler
// system notification, console log, emit end (so watch continues)
var onError = function(error) {
notifier.notify({
'title': 'Error',
'message': 'Compilation failure.'
});
console.log(error);
this.emit('end');
}
// concat and uglify scripts
gulp.task('scripts', function() {
return gulp.src('src/layzr.js')
.pipe(plugins.plumber({ errorHandler: onError }))
.pipe(plugins.umd())
.pipe(plugins.header(banner, { pkg: packageJSON }))
.pipe(gulp.dest('dist'))
.pipe(plugins.uglify({ preserveComments: 'some' }))
.pipe(plugins.rename(function(path) {
path.basename = "layzr.min"
}))
.pipe(gulp.dest('dist'));
});
// start local server on port 3000
gulp.task('server', function() {
return plugins.connect.server({
root: './',
port: 3000,
livereload: true
});
});
// watch sass and js files
gulp.task('watch', function() {
gulp.watch('src/layzr.js', ['scripts']);
});
// build and default task
gulp.task('default', ['server', 'scripts', 'watch']);