'use strict'

let gulp = require('gulp')
let sass = require('gulp-sass')
let typescript = require('gulp-tsc')
let browserSync = require('browser-sync').create()

gulp.task('default', ['watch']);

gulp.task('watch', ['watch.ts', 'watch.sass'])

gulp.task('setup', ['ts', 'sass'], () => {
	gulp.src(['node_modules/angular2/bundles/**/*'])
		.pipe(gulp.dest('public/javascripts/angular2'))
})

gulp.task('ts', () => {
	let tscConfig = require('./client/tsconfig.json')

	var tsResult = gulp
		.src(['client/**/*.ts'])
		.pipe(typescript(tscConfig.compilerOptions));

	return tsResult.pipe(gulp.dest('public/javascripts/'));
})

gulp.task('ts.html', () => {
	gulp.src(['client/**/*.html'])
		.pipe(gulp.dest('public/javascripts/'))
})

gulp.task('watch.ts', ['ts', 'ts.html'], () => {
	gulp.watch('client/**/*', ['ts', 'ts.html'])
		// .pipe(browserSync.stream());
})

gulp.task('sass', () => {
	return gulp.src('./public/sass/main.scss')
		.pipe(sass().on('error', sass.logError))
		.pipe(gulp.dest('./public/stylesheets'))
		.pipe(browserSync.stream({match: '**/*.css'}))
})

gulp.task('watch.sass', ['sass', 'browser-sync'], function () {
	gulp.watch('./public/sass/**/*.scss', ['sass'])
})

gulp.task('browser-sync', function() {
	browserSync.init({
		proxy: "localhost:3000"
	})
})

@@ -622,115 +622,8 @@
 %7D)%0A%0A
-gulp.task('ts.html', () =%3E %7B%0A%09gulp.src(%5B'client/**/*.html'%5D)%0A%09%09.pipe(gulp.dest('public/javascripts/'))%0A%7D)%0A%0A
 gulp
@@ -645,27 +645,16 @@
 ', %5B'ts'
-, 'ts.html'
 %5D, () =%3E
@@ -692,19 +692,8 @@
 'ts'
-, 'ts.html'
 %5D)%0A%09

Remove html components