This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
67 lines (57 loc) · 1.54 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
const { ensureDirSync } = require('fs-extra');
const webpack = require('webpack-stream');
const htmlmin = require('gulp-htmlmin');
const lint = require('gulp-eslint');
const gulp = require('gulp');
const del = require('del');
gulp.task('clean', () =>
del([
'build/**',
'!build',
'!build/static',
'!build/static/uploads',
'!build/static/uploads/**'
])
);
gulp.task('copy', ['clean'], () => {
ensureDirSync('build/static/uploads');
return [
gulp.src([
'src/index.html'
])
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('build/')),
gulp.src([
'src/images/**/*'
])
.pipe(gulp.dest('build/static/images'))
];
});
gulp.task('dev:client', () =>
gulp.src('src/client/client.js')
.pipe(webpack(require('./webpack/client/dev.js')))
.pipe(gulp.dest('build/static/js'))
);
gulp.task('prod:client', () =>
gulp.src('src/client/client.js')
.pipe(webpack(require('./webpack/client/prod.js')))
.pipe(gulp.dest('build/static/js'))
);
gulp.task('dev:server', () =>
gulp.src('src/server/app.js')
.pipe(webpack(require('./webpack/server/dev.js')))
.pipe(gulp.dest('build/'))
);
gulp.task('prod:server', () =>
gulp.src('src/server/app.js')
.pipe(webpack(require('./webpack/server/prod.js')))
.pipe(gulp.dest('build/'))
);
gulp.task('lint', () =>
gulp.src('src/**/*.js')
.pipe(lint())
.pipe(lint.format())
.pipe(lint.failAfterError())
);
gulp.task('dev', ['clean', 'copy', 'dev:client', 'dev:server']);
gulp.task('prod', ['clean', 'copy', 'prod:client', 'prod:server']);