forked from xiaolin/react-image-gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (75 loc) · 2.05 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
82
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', function () {
connect.server({
host: '0.0.0.0',
root: ['example', 'build'],
port: 8001,
livereload: true
})
})
gulp.task('sass', function () {
gulp.src('./src/image-gallery.scss')
.pipe(sass())
.pipe(rename('image-gallery.css'))
.pipe(gulp.dest('./build/'))
.pipe(livereload())
})
gulp.task('scripts', function() {
watchify(browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', {
plugins: ['transform-object-assign'],
presets: ['es2015', 'react']
}))
.bundle()
.pipe(source('example.js'))
.pipe(buffer())
.pipe(gulp.dest('./example/'))
.pipe(livereload())
})
gulp.task('demo-js', function() {
process.env.NODE_ENV = 'production'
browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', {
plugins: ['transform-object-assign'],
presets: ['es2015', 'react']
})
.bundle()
.pipe(source('demo.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./demo/'))
})
gulp.task('source-js', function () {
return gulp.src('./src/ImageGallery.jsx')
.pipe(concat('image-gallery.js'))
.pipe(babel({
plugins: ['transform-object-assign'],
presets: ['es2015', 'react']
}))
.pipe(gulp.dest('./build'))
})
gulp.task('watch', function() {
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'])
gulp.task('demo', ['demo-js'])