forked from dockwa/simple-react-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (48 loc) · 1.38 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
// include plug-ins
var gulp = require('gulp');
var umd = require('gulp-umd');
var inject = require('gulp-inject-string')
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var babel = require('gulp-babel');
var HEADER_COMMENT = '// Simple React Validator v1.0.7 | Created By Dockwa | MIT License | 2017 - Present\n';
var gutil = require('gulp-util');
// JS concat, strip debugging and minify
gulp.task('build', function() {
gulp.src('./src/simple-react-validator.js')
.pipe(babel())
.pipe(umd({
exports: function() {
return 'SimpleReactValidator';
},
namespace: function() {
return 'SimpleReactValidator';
},
dependencies: function() {
return [
{
name: 'react',
amd: 'react',
cjs: 'react',
global: 'React',
param: 'React'
}
]
}
}))
.pipe(inject.prepend(HEADER_COMMENT))
// This will output the non-minified version
.pipe(gulp.dest('./dist/'))
// minify
.pipe(uglify().on('error', function(err) {
gutil.log(gutil.colors.red('[Error]'), err.toString());
this.emit('end');
}))
.pipe(inject.prepend(HEADER_COMMENT))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch', function() {
gulp.watch(['src/*'], ['build']);
});
gulp.task('dist', ['build']);