-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (50 loc) · 1.53 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
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var connect = require('gulp-connect');
var open = require('gulp-open');
var sass = require('gulp-sass');
var port = process.env.port || 3000;
gulp.task('sass', function() {
gulp.src('./src/styles/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./src/dist'));
});
gulp.task('browserify', function() {
browserify('./src/app/app.js')
.transform('reactify', { 'es6': true })
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./src/dist'));
});
gulp.task('connect', function() {
connect.server({
root: 'src',
port: port,
livereload: true
});
});
gulp.task('open', function(){
var options = {
url: 'http://localhost:' + port,
};
gulp.src('./src/index.html').pipe(open('', options));
});
gulp.task('html', function () {
gulp.src('./src/*.html').pipe(connect.reload());
});
gulp.task('js', function () {
gulp.src('./src/dist/**/*.js').pipe(connect.reload());
});
gulp.task('css', function () {
gulp.src('./src/dist/**/*.css').pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('./src/index.html', ['html']);
gulp.watch('./src/dist/**/*.js', ['js']);
gulp.watch('./src/dist/**/*.css', ['css']);
gulp.watch('./src/styles/**/*.scss', ['sass']);
gulp.watch('./src/app/**/*.js', ['browserify']);
});
gulp.task('default', ['browserify', 'sass']);
gulp.task('serve', ['browserify', 'sass', 'connect', 'open', 'watch']);