-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathgulpfile.js
83 lines (72 loc) · 1.68 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
'use strict';
/**
* @file Gulp tasks.
* @example gulp // Default task. Builds and serves the app.
* @example gulp build --distDir='~/Encryptic-dist' // To build the project and
* place it in ~/Encryptic-dist folder.
*/
const gulp = require('gulp'),
pkg = require('./package.json'),
gulpLoadPlugins = require('gulp-load-plugins');
const $ = gulpLoadPlugins({
pattern : ['del', 'through2'],
overridePattern : false,
});
$.browserSync = require('browser-sync').create();
$.minimist = require('minimist')(process.argv.slice(2));
$.distDir = $.minimist.distDir || './dist';
/**
* Create a new Gulp task.
*
* @param {String} name - name of the task file
*/
function createTask(name) {
const task = require(`./gulps/${name}`)(gulp, $, pkg);
if (typeof task === 'function') {
gulp.task(name, task);
}
}
// Load and create tasks
[
'bundle',
'clean',
'css',
'electron',
'html',
'lint',
'npm',
'serve',
'test',
'copy',
'copyDist',
].forEach(createTask);
/**
* Build the app.
* `gulp build --dev` to build without minifying.
*/
gulp.task('build', gulp.series(
'clean:dist',
gulp.parallel('bundle', 'copy', 'css', 'html')
));
// Load mobile tasks
createTask('mobile');
// Prepare the release files.
gulp.task('release', gulp.series(
'build',
'clean:release',
'copyDist',
'npm:install',
'electron'
));
// Build for android
gulp.task('release-mobile', gulp.series(
'clean:release',
'copyDist',
'npm:install',
'mobile:build'
));
/**
* Gulp server.
* ``gulp --root dist`` to serve dist folder.
*/
gulp.task('default', gulp.series('build', 'serve'));