-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (59 loc) · 1.81 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
var gulp = require('gulp');
var gutil = require("gulp-util");
var merge2 = require('merge2');
var webpack = require('webpack');
var rm = require('gulp-rm');
var runSequence = require('run-sequence');
var packager = require('electron-packager');
// var asar = require('asar');
gulp.task('default', ['dist']);
gulp.task('build', ['copy'], function (callback) {
webpack(require('./webpack.config'), function (err, stats) {
if (err) throw new gutil.PluginError('build', err);
if (stats.hasErrors || stats.hasWarnings) {
gutil.log('[webpack]', stats.toString({
chunks: false,
errorDetails: true,
modules: false
}));
}
callback();
});
});
function copy(base, files, dest) {
if (!Array.isArray(files)) files = [files];
for (var i = 0; i < files.length; i++) {
files[i] = base + files[i];
}
return gulp.src(files, {base: base}).pipe(gulp.dest(dest));
}
gulp.task('copy', function () {
return merge2([
copy('src/', ['app/index.html', '**/*.js', '**/*.png'], 'build/'),
copy('node_modules/bootstrap/dist/', ['css/bootstrap.min.css*', 'fonts/*'], 'build/styles')
]);
});
gulp.task('dist', ['build'], function (callback) {
packager(require('./packager.config'), function done (err, appPath) {
if (err) throw new gutil.PluginError('build', err);
callback();
});
// asar.createPackage('build/', 'app.asar', function (err) {
// if (err) throw new gutil.PluginError('build', err);
// callback();
// });
});
gulp.task('clean', function () {
return gulp.src([
'build/**/*',
'!build/node_modules/**/*',
'!build/node_modules/',
'!build/package.json',
'build/**/.DS_Store',
'dist/**/*',
'*.asar'
], {
read: false
}).pipe(rm());
});
gulp.task('publish', function (callback) { runSequence('clean', 'dist', callback); });