-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (42 loc) · 1.27 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var react = require('gulp-react');
var notify = require('gulp-notify');
var streamify = require('gulp-streamify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var paths = {
scripts: 'js/**/*.js',
jsx: 'js/**/*.jsx'
};
gulp.task('jsx', function() {
return gulp
.src(paths.jsx)
.pipe(react())
.pipe(gulp.dest('js/'));
});
gulp.task('jshint', function() {
return gulp
.src(paths.scripts)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
});
gulp.task('scripts', function() {
return browserify('./js/wopidy.js')
.bundle()
.pipe(source('wopidy.js'))
.pipe(gulp.dest('build/assets/js'))
.pipe(rename({suffix: '.min'}))
.pipe(streamify(uglify()))
.pipe(gulp.dest('build/assets/js'))
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('watch', function() {
// jsx task will trigger scripts task when writing js files
gulp.watch(paths.jsx, ['jsx']);
gulp.watch(paths.scripts, ['jshint', 'scripts']);
});
gulp.task('default', ['jsx', 'jshint', 'scripts', 'watch']);