aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ts-loader/examples/react-babel-karma-gulp/gulpFile.js
blob: 03c6a6b4eb238485c74dbcf9a40dea194b246507 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';

var gulp = require('gulp');
var gutil = require('gulp-util');
var webpack = require('./gulp/webpack');
var staticFiles = require('./gulp/staticFiles');
var tests = require('./gulp/tests');
var clean = require('./gulp/clean');
var inject = require('./gulp/inject');

gulp.task('delete-dist', function (done) {
  clean.run(done);
});

gulp.task('build-js', ['delete-dist'], function(done) {
  webpack.build().then(function() { done(); });
});

gulp.task('build-other', ['delete-dist'], function() {
  staticFiles.build();
});

gulp.task('build', ['build-js', 'build-other'], function () {
  inject.build();
});

gulp.task('watch', ['delete-dist'], function(done) {
  Promise.all([
    webpack.watch()
  ]).then(function() {
    gutil.log('Now that initial assets (js and css) are generated inject will start...');
    inject.watch();
    done();
  }).catch(function(error) {
    gutil.log('Problem generating initial assets (js and css)', error);
  });

  staticFiles.watch();
  tests.watch();
});

gulp.task('watch-and-serve', ['watch'], function() {
  // local as not required for build
  var express = require('express')
  var app = express()

  app.use(express.static('dist', {'index': 'index.html'}))
  app.listen(8080);
});