-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
81 lines (61 loc) · 2.04 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
var gutil = require('gulp-util'),
sass = require('gulp-sass'),
gulp = require('gulp'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat')
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload'),
prefix = require('gulp-autoprefixer'),
livereloadport = 35729,
serverport = 8080;
// server --------------------------------- //
var server = express();
server.use(livereload({
port: livereloadport
}));
server.use(express.static('./build'));
gulp.task('serve', function() {
server.listen(serverport);
lrserver.listen(livereloadport);
});
// main tasks ------------------------------ //
gulp.task('styles', function(){
gulp.src('./app/sass/application.scss')
.pipe(sass({sourceComments: 'map'}))
.pipe(prefix())
.pipe(gulp.dest('./build/assets/css/'))
.pipe(refresh(lrserver));
});
gulp.task('scripts', function(){
gulp.src(['./app/js/app.js'])
.pipe(browserify({
debug: true,
transform: [ 'reactify' ]
}))
.pipe(gulp.dest('./build/assets/js/'))
.pipe(refresh(lrserver));
});
gulp.task('html', function(){
gulp.src('./app/index.html')
.pipe(gulp.dest('./build/'))
.pipe(refresh(lrserver));
});
gulp.task('assets', function(){
gulp.src('./app/assets/**/*')
.pipe(gulp.dest('./build/assets/'))
.pipe(refresh(lrserver));
});
// watch ---------------------------------- //
gulp.task('watch', function() {
gulp.watch('app/sass/**', ['styles']);
gulp.watch('app/js/**', ['scripts']);
gulp.watch('app/assets/**', ['assets']);
gulp.watch('app/index.html', ['html']);
});
// build ---------------------------------- //
gulp.task('build', ['html', 'scripts', 'styles', 'assets']);
// gulp ---------------------------------- //
gulp.task('default', ['scripts', 'styles', 'html', 'assets', 'serve', 'watch']);