2015-10-17 14:12:04 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var sourcemaps = require('gulp-sourcemaps');
|
2015-09-26 14:02:03 +02:00
|
|
|
var browserSync = require('browser-sync').create();
|
2015-10-18 20:05:30 +02:00
|
|
|
var del = require('del');
|
2015-10-18 23:34:07 +02:00
|
|
|
var flatten = require('gulp-flatten');
|
2015-10-21 22:05:49 +02:00
|
|
|
var ts = require('gulp-typescript');
|
|
|
|
var merge = require('merge2');
|
|
|
|
var concat = require('gulp-concat');
|
2015-09-26 14:02:03 +02:00
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
var tsProject = ts.createProject('tsconfig.json');
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
gulp.task('scripts', function() {
|
|
|
|
var tsResult = gulp.src('src/*.ts')
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(ts(tsProject));
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
return tsResult.js
|
|
|
|
.pipe(concat('bundle.js'))
|
|
|
|
.pipe(sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
2015-10-17 14:12:04 +02:00
|
|
|
|
2015-10-18 20:05:30 +02:00
|
|
|
gulp.task('dist', ['dist-node-modules'], function () {
|
|
|
|
return gulp.src([
|
|
|
|
'src/**/*.html',
|
|
|
|
'src/**/*.css',
|
|
|
|
'src/**/*.js'
|
|
|
|
], {base: 'src'})
|
2015-10-21 22:05:49 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest('dist'));
|
2015-10-18 20:05:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('dist-node-modules', function () {
|
|
|
|
return gulp.src([
|
2015-10-21 22:05:49 +02:00
|
|
|
'node_modules/bootstrap/**/*',
|
|
|
|
'node_modules/angular/**/*',
|
|
|
|
'node_modules/jquery/**/*'
|
2015-10-18 20:05:30 +02:00
|
|
|
], {base: 'node_modules'})
|
2015-10-21 22:05:49 +02:00
|
|
|
.pipe(gulp.dest('dist/vendor'));
|
2015-10-18 20:05:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('clean', function () {
|
|
|
|
return del('dist');
|
|
|
|
});
|
|
|
|
|
2015-10-21 22:05:49 +02:00
|
|
|
gulp.task('serve', ['scripts', 'dist', 'dist-node-modules'], function () {
|
2015-09-26 14:02:03 +02:00
|
|
|
|
|
|
|
// Serve files from the root of this project
|
|
|
|
browserSync.init({
|
|
|
|
server: {
|
2015-10-18 20:05:30 +02:00
|
|
|
baseDir: "./dist",
|
2015-09-26 14:02:03 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// add browserSync.reload to the tasks array to make
|
|
|
|
// all browsers reload after tasks are complete.
|
2015-10-21 22:05:49 +02:00
|
|
|
gulp.watch("src/**/*.ts", ['scripts']);
|
2015-10-17 14:12:04 +02:00
|
|
|
gulp.watch([
|
2015-10-18 20:05:30 +02:00
|
|
|
"src/**/*.html",
|
|
|
|
"src/**/*.css",
|
2015-10-21 22:05:49 +02:00
|
|
|
"src/**/*.js"
|
|
|
|
], ['dist']);
|
|
|
|
gulp.watch("dist/**/*").on("change", browserSync.reload);
|
2015-09-26 14:02:03 +02:00
|
|
|
});
|