summaryrefslogtreecommitdiffhomepage
path: root/gui/tasks/scripts.js
blob: 8fc7155d4b8d8c42ea7cf2376c5c637a218ed86f (plain)
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
const { parallel, series, src, dest } = require('gulp');
const envify = require('gulp-envify');
const ts = require('gulp-typescript');

const TscWatchClient = require('tsc-watch/client');

function makeWatchCompiler(onFirstSuccess) {
  const compileScripts = function() {
    const watch = new TscWatchClient();
    watch.on('first_success', onFirstSuccess);
    watch.start('--noClear', '--sourceMap', '--project', '.');
    return watch.tsc;
  };
  compileScripts.displayName = 'compile-scripts-watch';

  return compileScripts;
}

function compileScripts() {
  const tsProject = ts.createProject('tsconfig.json');

  return tsProject
    .src()
    .pipe(tsProject())
    .pipe(envify({ NODE_ENV: 'production' }))
    .pipe(dest('build'));
}

compileScripts.displayName = 'compile-scripts';

exports.build = compileScripts;
exports.makeWatchCompiler = makeWatchCompiler;