-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
107 lines (86 loc) · 2.62 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
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
var gulp = require('gulp');
var rename = require('gulp-rename');
// Build
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync').create();
// Style
var less = require('gulp-less');
var prefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
// Development Dependencies
var jshint = require('gulp-jshint');
// Test Dependencies
var mochaPhantomjs = require('gulp-mocha-phantomjs');
// JSHint
gulp.task('lint-client', function() {
return gulp.src('./client/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('lint-test', function() {
return gulp.src('./test/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Browserify
gulp.task('browserify-client', ['lint-client'], function() {
return browserify('client/index.js', { insertGlobals: true })
.bundle()
.pipe(source('converter.js'))
.pipe(gulp.dest('build'))
.pipe(gulp.dest('public/js'));
browserSync.reload;
});
gulp.task('browserify-test', ['lint-test'], function() {
return browserify('test/client/index.js', { insertGlobals: true })
.bundle()
.pipe(source('client-test.js'))
.pipe(gulp.dest('build'));
});
// Serve
gulp.task('serve', ['watch'], function() {
browserSync.init({
server: {
baseDir: "./public"
}
});
});
// Testing
gulp.task('test', ['lint-test', 'browserify-test'], function() {
return gulp.src('test/client/index.html')
.pipe(mochaPhantomjs());
});
gulp.task('watch', function() {
gulp.watch('client/**/*.js', ['browserify-client', 'test']);
gulp.watch('test/client/**/*.js', ['test']);
});
gulp.task('bootstrap', function() {
return gulp.src('node_modules/bootstrap/dist/css/bootstrap.min.css')
.pipe(gulp.dest('build'))
.pipe(gulp.dest('public/css'));
});
// Assets
gulp.task('styles', ['bootstrap'], function() {
return gulp.src('client/less/index.less')
.pipe(less())
.pipe(prefix({ cascade: true }))
.pipe(rename('converter.css'))
.pipe(gulp.dest('build'))
.pipe(gulp.dest('public/css'));
});
gulp.task('minify', ['styles'], function() {
return gulp.src('build/converter.css')
.pipe(minifyCSS())
.pipe(rename('converter.min.css'))
.pipe(gulp.dest('public/css'));
});
gulp.task('uglify', ['browserify-client'], function() {
return gulp.src('build/converter.js')
.pipe(uglify())
.pipe(rename('converter.min.js'))
.pipe(gulp.dest('public/js'));
});
gulp.task('build', ['uglify', 'minify']);
gulp.task('default', ['test', 'build', 'watch', 'serve']);