-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (62 loc) · 1.76 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
var gulp = require('gulp');
uglify = require('gulp-uglify'),
htmlreplace = require('gulp-html-replace'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
reactify = require('reactify'),
streamify = require('gulp-streamify'),
notify = require('gulp-notify'),
connect = require('gulp-connect'),
less = require('gulp-less'),
livereload = require('gulp-livereload');
// TODO: Production settings
var path = {
MINIFIED_JS_OUTPUT_FILE: 'build.min.js',
JS_OUTPUT_FILE: 'build.js',
SRC_LESS_FILE: 'media/src/less/style.less',
SRC_LESS_SCOPE: 'media/src/less/*.less',
DEST: 'media/dist',
DEST_JS: 'media/dist/js',
DEST_CSS: 'media/dist/css',
DEST_BUILD: 'media/dist/build',
ENTRY_POINT: './media/src/js/main.js'
};
function bundleErrorHandler(err) {
if (err) {
gulp.src('').pipe(notify(err.toString()));
}
}
gulp.task('watch', function() {
// Listen localhost
livereload.listen();
// Watch less compile
gulp.watch([path.SRC_LESS_SCOPE], ['less-compile']);
var watcher = watchify(browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
debug: true,
cache: {}, packageCache: {}, fullPaths: true
}));
watcher.on('update', function() {
watcher.bundle()
.on('error', bundleErrorHandler)
.pipe(source(path.JS_OUTPUT_FILE))
.pipe(gulp.dest(path.DEST_JS))
.pipe(notify('== Successfully build =='))
.pipe(livereload())
})
.bundle()
.on('error', bundleErrorHandler)
.pipe(source(path.JS_OUTPUT_FILE))
.pipe(gulp.dest(path.DEST_JS))
.pipe(notify('== Successfully build =='))
.pipe(livereload())
});
gulp.task('less-compile', function() {
gulp.src(path.SRC_LESS_FILE)
.pipe(less())
.pipe(gulp.dest(path.DEST_CSS))
.pipe(livereload());
});
gulp.task('default', ['watch']);