tag-youre-it/Gulpfile.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

'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();
var del = require('del');
2015-10-18 23:34:07 +02:00
var flatten = require('gulp-flatten');
var ts = require('gulp-typescript');
var merge = require('merge2');
var concat = require('gulp-concat');
2015-09-26 14:02:03 +02:00
var tsProject = ts.createProject('tsconfig.json', {
sortOutput : true
});
gulp.task('scripts', function() {
var tsResult = gulp.src('src/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return tsResult.js
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(gulp.dest('dist'));
});
gulp.task('dist', ['dist-node-modules'], function () {
return gulp.src([
'src/**/*.html',
'src/**/*.css',
'src/**/*.js'
], {base: 'src'})
.pipe(flatten())
.pipe(gulp.dest('dist'));
});
gulp.task('dist-node-modules', function () {
return gulp.src([
'node_modules/bootstrap/**/*',
'node_modules/angular/**/*',
'node_modules/jquery/**/*'
], {base: 'node_modules'})
.pipe(gulp.dest('dist/vendor'));
});
gulp.task('clean', function () {
return del('dist');
});
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: {
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.
gulp.watch("src/**/*.ts", ['scripts']);
gulp.watch([
"src/**/*.html",
"src/**/*.css",
"src/**/*.js"
], ['dist']);
gulp.watch("dist/**/*").on("change", browserSync.reload);
2015-09-26 14:02:03 +02:00
});