-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
54 lines (47 loc) · 1.35 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
var fs = require('fs');
var gulp = require('gulp');
var sass = require('gulp-sass');
var react = require('gulp-react');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var connect = require('gulp-connect');
function getFiles(dir){
return fs.readdirSync(dir);
}
gulp.task('sass', function () {
gulp.src('./sass/main.scss')
.pipe(sass())
.pipe(gulp.dest('./dist/css'));
});
gulp.task('react', function(){
gulp.src('./jsx/**/*.jsx')
.pipe(react())
.pipe(gulp.dest('./scripts/components'));
});
gulp.task('scripts', function() {
var dir = './scripts/app/';
var files = getFiles(dir);
files.forEach(function(file){
browserify([dir + file]).bundle()
.pipe(source(file))
.pipe(gulp.dest('./dist/js/'));
});
});
gulp.task('connect', function() {
connect.server({
root: 'dist',
livereload: true,
middleware: function (connect, opt) {
var Proxy = require('gulp-connect-proxy');
opt.route = '/proxy';
var proxy = new Proxy(opt);
return [proxy];
}
});
});
gulp.task('watch', function() {
gulp.watch('./sass/**/*.scss', ['sass']);
gulp.watch('./jsx/**/*.jsx', ['react', 'scripts']);
gulp.watch('./scripts/**/*.js', ['scripts']);
});
gulp.task('default', ['sass', 'react', 'scripts']);