forked from carlosazaustre/universal-js-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
87 lines (76 loc) · 2.09 KB
/
gulpfile.babel.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
/*
* Universal JS Boilerplate
* Copyright (c) Carlos Azaustre, carlosazaustre.es
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import stylint from 'gulp-stylint';
import jscs from 'gulp-jscs';
import babelify from 'babelify';
import browserify from 'browserify';
import stylus from 'gulp-stylus';
import nib from 'nib';
import minifyCSS from 'gulp-minify-css';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
// -- Tasks --------------------------------------------------------------------
gulp.task('default', ['build', 'watch']);
gulp.task('build', ['build:js', 'build:css']);
// -- Linters
gulp.task('eslint', () => {
return gulp
.src(['./src/app/**/*.js', './src/app/**/*.jsx'])
.pipe(jscs())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('stylint', () => {
return gulp
.src([
'./src/styles/**/*.styl',
'./src/app/shared/components/**/*.styl',
'!./src/styles/base/normalize.styl',
])
.pipe(stylint({ config: '.stylintrc' }));
});
// -- Builders
gulp.task('build:js', ['eslint'], () => {
return browserify({
entries : './src/app/client/index.js',
debug : true,
extensions: ['.js', '.jsx'],
transform : babelify,
})
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(gulp.dest('./build/public'));
});
gulp.task('build:css', ['stylint'], () => {
return gulp
.src('./src/styles/app.styl')
.pipe(stylus({
use: nib(),
'include css': true,
}))
.pipe(minifyCSS())
.pipe(gulp.dest('./build/public'));
});
// -- Watch files
gulp.task('watch', () => {
gulp.watch([
'./src/app/server/index.js',
'./src/app/client/index.js',
'./src/app/shared/components/**/*.jsx',
'./src/app/shared/routes.js'
], ['build:js']);
gulp.watch([
'./src/styles/**/*.styl',
'./src/app/shared/components/**/*.styl',
], ['build:css']);
});