-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (48 loc) · 1.56 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
const { src, dest, lastRun, watch, parallel, series } = require('gulp');
const webpack = require('webpack')
const ts = require("gulp-typescript");
const del = require('del');
let webpackConfig = require('./webpack.config.js')
// runs webpack using the above config
function renderer(cb) {
// run webpack
return new Promise((resolve, reject) => {
webpack(webpackConfig, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
return reject(new Error(stats.stats[0].compilation.errors.join('\n')))
}
resolve()
})
})
}
// copies all .js files from app/main to dist/main
function copyMain(cb) {
return src('app/main/*.js', { since: lastRun(copyMain) })
.pipe(dest('dist/main/'));
}
// Runs .ts files in app/main through the typescript compiler, then places them in dist/main
function tsMain(cb) {
return src('app/main/*.ts', { since: lastRun(tsMain) })
.pipe(ts({
module: "commonjs",
removeComments: true,
isolatedModules: true,
}))
.pipe(dest('dist/main/'));
}
function clean(cb) {
return del(['dist'], cb);
}
//if (process.env.NODE_ENV === 'production')
exports.default = parallel(renderer, copyMain, tsMain)
exports.clean = clean
exports.main = parallel(copyMain, tsMain)
exports.watch = function () {
//watch('app/renderer/*', renderer);
//watch('app/renderer/*.css', renderer);
watch('app/main/*.js', copyMain);
watch('app/main/*.ts', tsMain);
}