forked from felixrieseberg/React-Dropzone-Component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (57 loc) · 1.93 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
var del = require('del');
var gulp = require('gulp');
var webpack = require('webpack-stream');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var plumber = require('gulp-plumber');
var react = require('gulp-react');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var pkg = require('./package.json');
var devBuild = gutil.env.release ? '' : ' (dev build at ' + (new Date()).toUTCString() + ')';
var distHeader = '/*!\n\
* <%= pkg.name %> <%= pkg.version %><%= devBuild %> - <%= pkg.homepage %>\n\
* Copyright (C) Felix Rieseberg <[email protected]>\n\
* <%= pkg.license %> Licensed\n\
*/\n';
var jsSrcPaths = './src/*.js';
var jsLibPaths = './lib/**/*.js';
gulp.task('clean-lib', function(cb) {
del('./lib', cb);
});
gulp.task('transpile-js', ['clean-lib'], function() {
return gulp.src(jsSrcPaths)
.pipe(plumber())
.pipe(react({
harmony: true
}))
.pipe(gulp.dest('./lib'));
});
gulp.task('lint-js', ['transpile-js'], function() {
return gulp.src(jsLibPaths)
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('bundle-js', ['lint-js'], function() {
var stream = gulp.src('./lib/react-dropzone.js')
.pipe(streamify(header(distHeader, {
pkg: pkg,
devBuild: devBuild
})))
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('./dist'))
.pipe(rename('react-dropzone.min.js'))
.pipe(streamify(uglify()))
.pipe(streamify(header(distHeader, {
pkg: pkg,
devBuild: devBuild
})))
.pipe(gulp.dest('./dist'));
return stream;
});
gulp.task('watch', function() {
gulp.watch(jsSrcPaths, ['bundle-js']);
});
gulp.task('default', ['transpile-js', 'bundle-js']);