-
Notifications
You must be signed in to change notification settings - Fork 23
/
gulpfile.js
61 lines (49 loc) · 1.65 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
'use strict';
var gulp = require('gulp');
var rename = require('gulp-rename');
function lint(cb) {
var jshint = require('gulp-jshint');
return gulp.src('./**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
}
gulp.task(lint);
function browserify(cb) {
var browserify = require('browserify');
var source = require('vinyl-source-stream');
return browserify('./public/javascript/room.js')
.bundle()
.pipe(source('room.bundle.js'))
.pipe(gulp.dest('./public/javascript/'));
}
gulp.task(browserify);
function minifyCss() {
var minifyCss = require('gulp-minify-css');
return gulp.src(['!./**/*.min.css', 'public/stylesheet/**/*.css'])
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('public/stylesheet'));
}
gulp.task(minifyCss);
function _minifyJs() {
var uglify = require('gulp-uglify');
return gulp.src(['!./**/*.min.js', './public/javascript/*.js'])
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./public/javascript/'));
}
gulp.task('minifyJs', gulp.series(browserify, _minifyJs));
function _start() {
var nodemon = require('gulp-nodemon');
nodemon({
script: 'app.js',
ext: 'js',
tasks: ['lint', 'browserify'],
ignore: ['*.bundle.js', '*.min.js'],
env: {'NODE_ENV': 'development'}
});
}
gulp.task('start', gulp.series(lint, browserify, _start));
gulp.task('build:development', gulp.series(lint, browserify));
gulp.task('build:production', gulp.parallel(minifyCss, gulp.task('minifyJs')));
gulp.task('default', gulp.task('start'));