-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·75 lines (63 loc) · 2.22 KB
/
gulpfile.js
File metadata and controls
executable file
·75 lines (63 loc) · 2.22 KB
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
var gulp = require('gulp')
, browserify = require('browserify') //from a single JavaScript file, follows the require dependency tree, and bundles them into a single file
, reactify = require('reactify') //converts jsx to js
, source = require('vinyl-source-stream') //transforms the string output from browserify to a gulp stream
, livereload = require('gulp-livereload')
, embedlr = require('gulp-embedlr')
, shell = require('gulp-shell')
, concatCss = require('gulp-concat-css')
, minifyCss = require('gulp-minify-css')
, uglify = require('gulp-uglify')
, buffer = require('vinyl-buffer')
;
var jsxSources = [
'src/jsx/*.jsx'
];
var htmlSources = [
'src/*.html'
];
var cssSources = [
'./node_modules/react-widgets/dist/css/react-widgets.css'
, './node_modules/bootstrap/dist/css/bootstrap.min.css'
, 'src/css/*.css'
];
var fontSources = [
'./node_modules/bootstrap/fonts/*'
];
gulp.task('browserify', function(){
browserify('src/jsx/main.jsx') //browserify starting point
.transform('reactify') //jsx to js
.bundle()
.on('error', function(err){ console.log(err.message); })
.pipe(source('bundle.js')) //output stream
.pipe(buffer())
.pipe(uglify())
.on('error', function(err){ console.log(err); })
.pipe(gulp.dest('prod/js'))
.pipe(livereload())
;
});
gulp.task('html', function() {
gulp.src(htmlSources)
.pipe(embedlr({src:"http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"}))
.pipe(gulp.dest('prod/'))
.pipe(livereload())
});
gulp.task('css', function() {
gulp.src(cssSources)
.pipe(concatCss("styles/bundle.css"))
.pipe(minifyCss())
.pipe(gulp.dest('prod/'));
});
gulp.task('font', function() {
gulp.src(fontSources)
.pipe(gulp.dest('prod/bootstrap/dist/fonts/'));
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch(jsxSources, ['browserify']);
gulp.watch(htmlSources, ['html']);
gulp.watch(cssSources, ['browserify','css']);
//gulp.watch(sassSources, ['compass']);
});
gulp.task('default', ['browserify','html','css','font','watch']);