/
gulpfile.js
76 lines (67 loc) · 1.95 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var babel = require('gulp-babel');
var browserSync = require('browser-sync');
var nodemon = require('gulp-nodemon');
var reload = browserSync.reload;
var eslint = require('gulp-eslint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
gulp.task('js', function() {
return gulp.src(['client/vendor/*.js', 'client/*.js.es6'])
.pipe(concat('client/dist/app.js'))
.pipe(babel({ blacklist: ['useStrict'] }))
.pipe(gulp.dest('.'));
});
gulp.task('scss', function () {
return gulp.src('client/*.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest('client/dist/'));
});
gulp.task('js-dist', ['js'] ,function () {
return gulp.src('client/dist/app.js')
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('client/dist/'));
});
gulp.task('css-dist', ['scss'] ,function () {
return gulp.src('client/dist/app.css')
.pipe(minifyCss())
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('client/dist/'));
});
gulp.task('lint', function () {
return gulp.src('client/*.js.es6')
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('server', function (cb) {
var started = false;
return nodemon({
script: 'server.js'
}).on('start', function () {
if (!started) {
cb();
started = true;
}
}).on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
gulp.task('dev', ['server'], function() {
browserSync({
proxy: 'http://localhost:8000',
files: ['client/*.*'],
browser: 'google chrome',
port: 3000
});
gulp.watch('client/*.scss', ['scss']);
gulp.watch('client/*.js.es6', ['js']);
});
gulp.task('dist', ['js-dist', 'css-dist']);