-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
51 lines (44 loc) · 1.66 KB
/
gulpfile.js
File metadata and controls
51 lines (44 loc) · 1.66 KB
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
'use strict';
var gulp = require('gulp');
var execute = require('child_process').exec;
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var tsc = require('gulp-typescript');
var tscConfig = require('./tsconfig.json');
var browserSync = require('browser-sync').create();
// Run the server
gulp.task('runserver', function() {
var proc = execute('python3 server.py');
// For non-linux, uncomment the line below
// var proc = execute('python server.py');
});
// Copy the HTML templates
gulp.task('html-copy', function() {
return gulp
.src(['frontend/app/*.html', 'frontend/app/**/*.html'])
.pipe(gulp.dest('frontend/build/app'));
});
// Compile the SASS files
gulp.task('sass-compile', function() {
return gulp
.src(['frontend/app/*.scss', 'frontend/app/**/*.scss'])
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(concat('all.min.css'))
.pipe(gulp.dest('frontend/build'));
});
// Compile the TypeScript files
gulp.task('ts-compile', function() {
return gulp
.src(['frontend/app/*.ts', 'frontend/app/**/*.ts'])
.pipe(tsc(tscConfig.compilerOptions))
.pipe(gulp.dest('frontend/build/app'));
});
// Default run command
gulp.task('default', ['runserver', 'html-copy', 'sass-compile', 'ts-compile'], function() {
browserSync.init({ proxy: 'localhost:5000' });
// Watchers
gulp.watch(['frontend/app/*.html', 'frontend/app/**/*.html'], ['html-copy']);
gulp.watch(['frontend/app/*.scss', 'frontend/app/**/*.scss'], ['sass-compile']);
gulp.watch(['frontend/app/*.ts', 'frontend/app/**/*.ts'], ['ts-compile']);
gulp.watch('frontend/**/*.*', browserSync.reload);
});