forked from xiaolin/react-image-gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
92 lines (82 loc) · 2.46 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
83
84
85
86
87
88
89
90
91
92
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 cleanCSS = require('gulp-clean-css');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var babelOptions = {
plugins: ['transform-object-assign'],
presets: ['es2015', 'react', 'stage-0']
};
gulp.task('server', function () {
connect.server({
host: '0.0.0.0',
root: ['example', 'build', 'styles'],
port: 8001,
livereload: true
});
});
gulp.task('sass', function () {
gulp.src('./styles/scss/image-gallery.scss')
.pipe(sass())
.pipe(rename('image-gallery.css'))
.pipe(gulp.dest('./styles/css/'))
.pipe(livereload());
});
gulp.task('sass-no-icon', function () {
gulp.src('./styles/scss/image-gallery-no-icon.scss')
.pipe(sass())
.pipe(rename('image-gallery-no-icon.css'))
.pipe(gulp.dest('./styles/css/'))
.pipe(livereload());
});
gulp.task('scripts', function() {
watchify(browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', babelOptions))
.bundle()
.pipe(source('example.js'))
.pipe(buffer())
.pipe(gulp.dest('./example/'))
.pipe(livereload());
});
gulp.task('demo-src', function() {
process.env.NODE_ENV = 'production';
browserify({
entries: './example/app.js',
extensions: ['.jsx'],
debug: true
}).transform('babelify', babelOptions)
.bundle()
.pipe(source('demo.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./demo/'));
gulp.src(['./styles/css/image-gallery.css', './example/app.css'])
.pipe(concat('demo.css'))
.pipe(cleanCSS({keepSpecialComments: false}))
.pipe(gulp.dest('./demo/'));
});
gulp.task('source-js', function () {
return gulp.src('./src/ImageGallery.jsx')
.pipe(concat('image-gallery.js'))
.pipe(babel(babelOptions))
.pipe(gulp.dest('./build'));
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch(['styles/**/*.scss'], ['sass']);
gulp.watch(['src/*.jsx', 'example/app.js'], ['scripts']);
});
gulp.task('dev', ['watch', 'scripts', 'sass', 'server']);
gulp.task('build', ['source-js', 'sass', 'sass-no-icon']);
gulp.task('demo', ['demo-src']);