-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
81 lines (74 loc) · 1.96 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 babel = require('gulp-babel');
var browserify = require('browserify');
var concat = require('gulp-concat');
var connect = require('gulp-connect');
var gulp = require('gulp')
var livereload = require('gulp-livereload');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
gulp.task('server', () => {
connect.server({
host: '0.0.0.0',
root: ['example', 'build'],
port: 8001,
livereload: true
})
});
gulp.task('sass', () => {
gulp.src('./src/breakout.scss')
.pipe(sass())
.pipe(rename('breakout.css'))
.pipe(gulp.dest('./build/'))
.pipe(livereload())
});
gulp.task('scripts', () => {
watchify(browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', {
plugins: ['transform-runtime'],
presets: ['es2015', 'react']
}))
.bundle()
.pipe(source('example.js'))
.pipe(buffer())
.pipe(gulp.dest('./example/'))
.pipe(livereload())
});
gulp.task('demo-js', () => {
browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', {
plugins: ['transform-runtime'],
presets: ['es2015', 'react']
})
.bundle()
.pipe(source('demo.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./demo/'))
});
gulp.task('source-js', () => {
return gulp.src('./src/*.jsx')
.pipe(babel({
plugins: ['transform-runtime'],
presets: ['es2015', 'react']
}))
.pipe(gulp.dest('./build'))
});
gulp.task('watch', () => {
livereload.listen()
gulp.watch(['src/*.scss'], ['sass'])
gulp.watch(['src/*.jsx', 'example/app.js'], ['scripts'])
});
gulp.task('dev', ['watch', 'scripts', 'sass', 'server']);
gulp.task('build', ['source-js', 'sass']);
// NODE_ENV=production gulp demo
gulp.task('demo', ['demo-js']);