-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathgulpfile.js
More file actions
77 lines (63 loc) · 1.8 KB
/
gulpfile.js
File metadata and controls
77 lines (63 loc) · 1.8 KB
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
'use strict';
const del = require('del');
const gulp = require('gulp');
const gutil = require('gulp-util');
const env = require('gulp-env');
const webpack = require('webpack');
const shell = require('shelljs');
const config = require('./config');
// clean task
const cleanTask = (files) => () => {
del(files, (err, paths) => {
gutil.log('Deleted files/folders:\n', gutil.colors.cyan(paths.join('\n')));
});
};
gulp.task('clean', cleanTask([
`.${config.path.build}`,
`.${config.path.publicAssets}`,
]));
gulp.task('set-production-env', () => {
env({
vars: {
NODE_ENV: 'production',
},
});
});
gulp.task('compile-templates', (done) =>
shell.exec('npm run compile-templates', () => done())
);
gulp.task('frontend:watch', (done) =>
shell.exec('npm run frontend:watch', () => done())
);
gulp.task('frontend:build', ['set-production-env'], (done) => {
webpack(require('./config/webpack/client/production'))
.run((err, stats) => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({ colors: true }));
done();
});
});
gulp.task('backend:watch', (done) => {
let started = false;
webpack(require('./config/webpack/server/development'))
.watch(100, (err, stats) => {
if (!started) {
started = true;
done();
}
gutil.log('[webpack]', stats.toString({ colors: true }));
});
});
gulp.task('backend:build', ['set-production-env'], (done) => {
webpack(require('./config/webpack/server/production'))
.run((err, stats) => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({ colors: true }));
done();
});
});
gulp.task('build', ['clean', 'compile-templates', 'frontend:build', 'backend:build']);