forked from hexplus/orcid-api-walkthrough
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (68 loc) · 2.13 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
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
nodemon = require('gulp-nodemon'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
plumber = require('gulp-plumber');
// run livereload
gulp.task('livereload', function() {
tinylr = require('tiny-lr')();
tinylr.listen(35729);
});
function notifyLiveReload(event) {
var fileName = require('path').relative(__dirname, event.path);
tinylr.changed({
body: {
files: [fileName]
}
});
};
// Styles gulp task
gulp.task('styles', function () {
return (sass('./src/scss'))
.on('error', function (err) { console.log(err.message); })
.pipe(plumber())
.pipe(gulp.dest('./public/gulp_derived/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('./public/gulp_derived/css'))
.pipe(notify({ message: 'Styles task complete' }));
});
// Scripts
gulp.task('scripts', function() {
return gulp.src('./src/js/*.js')
.pipe(plumber())
.pipe(concat('client.js'))
.pipe(gulp.dest('./public/gulp_derived/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('./public/gulp_derived/js'))
.pipe(notify({ message: 'Custom Scripts task complete' }));
});
// Watch
gulp.task('watch', function() {
gulp.watch('./src/scss/*.scss', ['styles']);
gulp.watch('./src/js/*.js', ['scripts']);
gulp.watch('./public/**', notifyLiveReload);
gulp.watch('./views/**', notifyLiveReload);
});
// run express
gulp.task('express', function () {
nodemon({ script: 'server.js'
, ext: 'html js'
, ignore: ['ignored.js']
, tasks: ['lint'] })
.on('restart', function () {
console.log('restarted!')
})
});
// Default task
gulp.task('default', ['express','livereload','watch'], function() {
gulp.start('styles','scripts');
});