-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgulpfile.js
More file actions
116 lines (97 loc) · 3.33 KB
/
gulpfile.js
File metadata and controls
116 lines (97 loc) · 3.33 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var browserify = require('browserify');
var reactify = require('reactify');
var browserSync = require('browser-sync').create();
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
source = require('vinyl-source-stream'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
streamify = require('gulp-streamify'),
del = require('del'),
react = require('gulp-react');
gulp.task('css', function() {
return sass('src/css/', { style: 'expanded' })
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('public/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('public/css'))
.pipe(notify({ message: 'Sass task complete' }));
});
gulp.task('js', ['js-hint'], function() {
var b = browserify();
b.transform(reactify);
b.add('src/js/main.js')
return b.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('public/js'))
.pipe(rename({suffix: '.min'}))
.pipe(streamify(uglify()))
.pipe(gulp.dest('public/js'))
.pipe(notify({ message: 'JavaScript task complete', onLast: true }));
});
gulp.task('js-hint', function() {
return gulp.src('src/**/*.js')
.pipe(react())
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('img', function() {
return gulp.src('src/img/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('public/img'))
.pipe(notify({ message: 'Images task complete', onLast: true }));
});
gulp.task('csv', function() {
return gulp.src('src/csv/**/*')
.pipe(gulp.dest('public/csv'))
.pipe(notify({ message: 'CSV task complete', onLast: true }));
});
gulp.task('thirdparty-img', function() {
return gulp.src('thirdparty/**/*')
.pipe(gulp.dest('public/img/thirdparty'))
.pipe(notify({ message: 'Test images task complete', onLast: true }));
});
gulp.task('html', function() {
return gulp.src(['src/*.html', 'src/*.ico'])
.pipe(gulp.dest('public'))
.pipe(notify({ message: 'HTML task complete', onLast: true }));
});
gulp.task('clean', function(cb) {
del(['public/css', 'public/js', 'public/img', 'public'], cb)
});
gulp.task('default', ['clean'], function() {
gulp.start('css', 'js', 'img', 'csv', 'thirdparty-img', 'html');
});
gulp.task('build', ['clean'], function() {
gulp.start('css', 'js', 'img', 'csv', 'html');
});
gulp.task('watch', function() {
// Watch .html files
gulp.watch('src/*.html', ['html']);
// Watch .scss files
gulp.watch('src/css/**/*.scss', ['css']);
// Watch .js files
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('lib/**/*.js', ['js']);
// Watch image files
gulp.watch('src/img/**/*', ['img']);
gulp.watch('thirdparty/**/*', ['thirdparty-img']);
// Watch .csv files
gulp.watch('src/csv/**/*', ['csv']);
// Create browserSync server
browserSync.init({
server: {
baseDir: "./public/"
}
});
// Watch any files in public/, reload on change
gulp.watch(['public/**']).on('change', browserSync.reload);
});