This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
77 lines (62 loc) · 2.06 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
const decompress = require('gulp-decompress');
const gulp = require('gulp');
const gutil = require('gulp-util');
const map = require('vinyl-map');
const npmInstall = require('npm-i');
const path = require('path');
const remoteSrc = require('gulp-remote-src');
const rimraf = require('rimraf');
const webpack = require('webpack');
const webpackConfig = require('./webpack/webpack');
// Clean tasks
gulp.task('clean', cb => rimraf('dist,app', cb));
// Build tasks
gulp.task('build', ['build:js', 'build:html', 'build:resources']);
gulp.task('build:js', (cb) => {
webpack(webpackConfig, (err, stats) => {
if (err) throw new gutil.PluginError('build:js', err);
gutil.log('[build:js]', stats.toString({
colors: true,
}));
cb();
});
});
gulp.task('build:html', () =>
gulp.src('src/main/*.html').pipe(gulp.dest('app'))
);
gulp.task('build:resources', () =>
gulp.src('src/resources/**', { base: 'src' }).pipe(gulp.dest('app'))
);
// Watch task
gulp.task('watch', ['build'], () => {
gulp.watch('src/main/*.html', ['build:html']);
gulp.watch('src/**', ['build:js']);
gulp.watch('src/resources/**', ['build:resources']);
});
// Dist tasks
gulp.task('dist:package.json', () =>
gulp.src('package.json')
.pipe(map((chunk) => {
const data = JSON.parse(chunk.toString());
data.main = 'backend.js';
delete data.bin;
delete data.build;
delete data.devDependencies;
delete data.scripts;
return JSON.stringify(data, null, 2);
}))
.pipe(gulp.dest('app'))
);
gulp.task('dist:npm-install', ['dist:package.json'], cb =>
npmInstall({ path: 'app', args: ['--production'] }, cb)
);
gulp.task('dist:clean:notifier', ['dist:npm-install'], cb =>
rimraf(path.join('app/node_modules/node-notifier/vendor', 'terminal-notifier.out'), cb)
);
gulp.task('dist:build:notifier', ['dist:clean:notifier'], () =>
remoteSrc(['terminal-notifier.zip'], {
base: 'https://github.com/radiant-player/terminal-notifier/releases/download/radiant/',
})
.pipe(decompress())
.pipe(gulp.dest('app/node_modules/node-notifier/vendor'))
);