This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
50 lines (42 loc) · 1.55 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
const exec = require('child_process').exec;
const gulp = require('gulp');
const { parallel } = require('gulp');
const ON_DEATH = require('death')({ debug: true });
const webpackStream = require('webpack-stream');
const webpack = require('webpack');
const path = require('path');
let electronChild;
ON_DEATH((signal, err) => {
console.log('death');
if (electronChild) electronChild.kill();
exec('taskkill /F /IM electron.* /T', (err, stdout, stderr) => {
// Only write the error to console if there is one and it is something other than process not found.
if (err && err !== 'The process "electron.*" not found.') {
console.error(err);
}
process.exit();
});
});
process.env.ELECTRON_DEV = true;
/**
* Build SEA (both main and renderer)
*/
function buildRenderer(done) {
const stream = gulp.src(path.join(__dirname, './src/sea.js'))
.pipe(webpackStream(require('./build/webpack.renderer.js'), webpack))
.pipe(gulp.dest(path.join(__dirname, './dist/')));
stream.on('end', () => done());
}
function buildMain(done) {
const stream = gulp.src([path.join(__dirname, './devIndex.js')])
.pipe(webpackStream(require('./build/webpack.index.js'), webpack))
.pipe(gulp.dest(path.join(__dirname, './dist/')));
stream.on('end', () => done());
}
function buildExports(done) {
const stream = gulp.src(path.join(__dirname, './src/exports.ts'))
.pipe(webpackStream(require('./build/webpack.exports.js'), webpack))
.pipe(gulp.dest(path.join(__dirname, './')));
stream.on('end', () => done());
}
gulp.task('buildSEA', parallel(buildMain, buildRenderer, buildExports));