-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
93 lines (80 loc) · 2.57 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
const path = require('path');
const gulp = require('gulp');
const usemin = require('gulp-usemin');
const minifyHtml = require('gulp-minify-html');
const uglify = require('gulp-uglify');
const rev = require('gulp-rev');
const minifyCss = require('gulp-minify-css');
const clean = require('gulp-clean');
const flatten = require('gulp-flatten');
const eslint = require('gulp-eslint');
const htmlhint = require('gulp-htmlhint');
const gulpWebpack = require('gulp-webpack');
const mocha = require('gulp-mocha');
gulp.task('webpack', ['clean'], function() {
const webPackConfig = require('./webpack.config.js');
return gulp.src(path.resolve(__dirname, 'webclient', 'App.jsx'))
.pipe(gulpWebpack(webPackConfig))
.pipe(gulp.dest(path.resolve(__dirname, 'webclient', 'assets')));
});
gulp.task('usemin', ['clean', 'webpack'], function() {
return gulp.src(['webclient/*.html'])
.pipe(usemin({
html: [minifyHtml({
empty: true
})],
js: [uglify(), rev()],
inlinejs: [uglify()],
css: [rev()],
inlinecss: [minifyCss()]
})).pipe(gulp.dest('dist/server/public'));
});
gulp.task('copy:fonts', ['clean'], function() {
return gulp.src('webclient/**/*.ttf')
.pipe(flatten())
.pipe(gulp.dest('dist/server/public/fonts'));
});
gulp.task('copy:package.json', ['clean'], function() {
return gulp.src('package.json')
.pipe(gulp.dest('dist/'));
});
gulp.task('copy:server', ['clean'], function() {
gulp.src(['server/**/*'])
.pipe(gulp.dest('dist/server/'));
});
gulp.task('clean', function() {
return gulp.src('dist', {
read: false
})
.pipe(clean());
});
gulp.task('eslint', function() {
return gulp.src([
'gulpfile.js', 'webpack.config.js', '.eslintrc.js', 'server/**/*',
'webclient/**/*.jsx', '!dist/**/*'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('htmlhint', function() {
return gulp.src(['webclient/**/*.html', '!node_modules/**/*',
'!bower_components/**/*', '!dist/**/*'
])
.pipe(htmlhint({
htmlhintrc: '.htmlhintrc'
}))
.pipe(htmlhint.failReporter());
});
gulp.task('test', function() {
return gulp.src(['server/**/*.spec.js', '!node_modules/**/*',
'!bower_components/**/*'
], {
read: false
})
.pipe(mocha());
});
gulp.task('copy', ['copy:package.json', 'copy:server', 'copy:fonts']);
gulp.task('build', ['eslint', 'usemin', 'copy']);
gulp.task('lint', ['eslint', 'htmlhint']);
gulp.task('default', ['build']);