-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
77 lines (61 loc) · 2 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
//browserify to concatenate js, watchify to watch browserify
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var eslint = require('gulp-eslint');
var debug= require('gulp-debug');
function swallowError (error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit('end');
}
var path = {
MINIFIED_OUT: 'react-multi-select-dropdown.min.js',
OUT: 'react-multi-select-dropdown.js',
DEST: './dist/',
SRC : './src',
ENTRY_POINT: './src/index.js'
};
gulp.task('watch', function() {
gulp.watch(path.DEST+"js/**/*.js", ['lint']);
var watcher = watchify(browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
debug: true,
cache: {}, packageCache: {}, fullPaths: false
}));
return watcher.on('update', function () {
watcher.bundle()
.on('error', swallowError)
.pipe(source(path.OUT))
.pipe(debug({title: 'building:'}))
.pipe(gulp.dest(path.DEST))
console.log('Updated');
}).bundle();
});
gulp.task('lint', function () {
return gulp.src([path.SRC+"/**/*.js", '!'+path.SRC+'**/*.min.js'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(debug({title:'lint'}))
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
});
gulp.task('default', ['watch']);
gulp.task('build', function(){
browserify({
entries: [path.ENTRY_POINT],
transform: [reactify]
})
.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.DEST));
});
gulp.task('production', ['build']);