-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
123 lines (106 loc) · 2.85 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
'use strict';
var gulp = require('gulp');
var del = require('del');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var livereload = require('gulp-livereload');
var nodemon = require('gulp-nodemon');
var eslint = require('gulp-eslint');
var ga = require('gulp-ga');
var jade = require('gulp-jade');
gulp.task('clean', function () {
del.sync([
'./dist/assets',
'./dist/css',
'./dist/js',
'./dist/*.html'
]);
});
gulp.task('compile', ['lint-client'], function () {
var b = browserify();
b.transform(reactify);
b.add('./client/js/main.js');
return b.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('./dist/js'))
.pipe(livereload());
});
gulp.task('lint-client', function () {
return gulp.src([
'./client/**/*.js'
])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('lint-server', function () {
return gulp.src([
'./*.js',
'./server/**/*.js'
])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('less', function () {
return gulp.src('./client/less/main.less')
.pipe(less())
.pipe(autoprefixer())
.pipe(gulp.dest('./dist/css'))
.pipe(livereload());
});
gulp.task('html', function () {
return gulp.src('./client/**/*.html')
.pipe(ga({
uid: 'UA-59881274-1',
url: 'auto',
anonymizeIp: true
}))
.pipe(gulp.dest('./dist/'))
.pipe(livereload());
});
gulp.task('css', function () {
return gulp.src('./client/css/*.css')
.pipe(autoprefixer())
.pipe(gulp.dest('./dist/css'))
.pipe(livereload());
});
gulp.task('assets', function () {
return gulp.src('./client/assets/*')
.pipe(gulp.dest('./dist/assets'))
.pipe(livereload());
});
gulp.task('watch', ['build'], function () {
livereload.listen();
gulp.watch('./client/*.html', ['html']);
gulp.watch('./client/css/**/*.css', ['css']);
gulp.watch('./client/assets/*.*', ['assets']);
gulp.watch('./client/less/**/*.less', ['less']);
gulp.watch('./client/js/**/*.js', ['lint-client', 'compile']);
gulp.watch(['./*.js', './server/**/*.js'], ['lint-server']);
});
gulp.task('templates', function() {
var YOUR_LOCALS = {};
gulp.src(['./views/faq.jade', './views/privacypolicy.jade', './views/contact-us.jade'])
.pipe(jade({
locals: YOUR_LOCALS
}))
.pipe(gulp.dest('./dist/'))
});
gulp.task('run', ['build'], function () {
nodemon({
script: 'server.js',
env: { 'NODE_ENV': 'test' },
ext: 'js',
ignore: [
'gulpfile.js',
'client/**/*.js',
'dist/**/*.js',
'node_modules'
]
});
});
gulp.task('lint', ['lint-server', 'lint-client']);
gulp.task('build', ['clean', 'compile', 'lint', 'assets', 'less', 'css', 'html', 'templates']);
gulp.task('default', ['build', 'watch', 'run']);