-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (60 loc) · 1.71 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
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var del = require('del');
var source = require('vinyl-source-stream');
var stylus = require('gulp-stylus');
var minifyCSS = require('gulp-minify-css');
var concat = require('gulp-concat');
var paths = {
src: {
css: ['./src/css/libs/*.css', './src/css/**/*.styl', 'src/css/**/*.css'],
jsx: ['./src/jsx/**/*.jsx'], //Src JS files on which to watch
appJs: ['./src/jsx/App.jsx'], //Main JS file, browserify finds the deps
html: ['./src/*.html']
},
dest: {
dist: './dist',
css: './dist/css',
js: './dist/js'
}
};
gulp.task('clean:css', function(done) {
del(['./dist/css/**/*.css'], done);
});
gulp.task('clean:js', function(done) {
del(['./dist/js/**/*.js'], done);
});
gulp.task('clean:html', function(done) {
del(['./dist/*.html'], done);
});
gulp.task('css', ['clean:css'], function() {
return gulp.src(paths.src.css)
.pipe(stylus())
.pipe(minifyCSS())
.pipe(concat('style.min.css'))
.pipe(gulp.dest(paths.dest.css));
});
gulp.task('jsx', ['clean:js'], function () {
browserify({
entries: paths.src.appJs,
extensions: ['.jsx'],
debug: true
})
.transform(babelify)
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest(paths.dest.js));
});
gulp.task('html', ['clean:html'], function(){
gulp.src(paths.src.html)
.pipe(gulp.dest(paths.dest.dist));
});
// Rerun tasks whenever a file changes.
gulp.task('watch', function() {
gulp.watch(paths.src.css, ['css']);
gulp.watch(paths.src.jsx, ['jsx']);
gulp.watch(paths.src.html, ['html']);
});
// The default task (called when we run `gulp` from cli)
gulp.task('default', ['watch', 'css', 'jsx', 'html']);