Last active
August 29, 2015 14:26
-
-
Save sebald/26f3bedd0197375d89a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strcit'; | |
| var gulp = require('gulp'), | |
| ts = require('gulp-typescript'), | |
| sourcemaps = require('gulp-sourcemaps'), | |
| concat = require('gulp-concat'), | |
| browserSync = require('browser-sync'), | |
| reload = browserSync.reload, | |
| del = require('del'), | |
| assign = require('object-assign'), | |
| // Load configuration | |
| tsconfig = require('./tsconfig.json'), | |
| config = require('./gulpfile.config')(); | |
| /** | |
| * Clean up destination directory | |
| */ | |
| gulp.task('clean', function (done) { | |
| del([config.path.dest], done); | |
| }); | |
| /** | |
| * Reload browser (connected with browser sync) | |
| */ | |
| gulp.task('reload', reload ); | |
| /** | |
| * Copy vendors into destination | |
| */ | |
| gulp.task('vendor', function () { | |
| gulp.src(config.vendor) | |
| .pipe(gulp.dest(config.path.dest + '/vendor')); | |
| }); | |
| /** | |
| * Main (index.html) | |
| */ | |
| gulp.task('main', function () { | |
| gulp.src(config.main) | |
| .pipe(gulp.dest(config.path.dest)); | |
| }); | |
| /** | |
| * Transpile TypeScript | |
| */ | |
| gulp.task('tsc', ['clean'], function () { | |
| var tsResult; | |
| tsResult = gulp.src([ | |
| config.path.src + '/**/*.ts', | |
| 'typings/tsd.d.ts' | |
| ]) | |
| .pipe(sourcemaps.init()) | |
| .pipe(ts(tsconfig))); | |
| tsResult.js | |
| .pipe(sourcemaps.write('.')) | |
| .pipe(gulp.dest(config.path.dest)); | |
| }); | |
| /** | |
| * Start developing (server + livereload) | |
| */ | |
| gulp.task('start', ['default'], function ( done ) { | |
| gulp.watch(config.path.src + '/**/*.ts', ['tsc', 'reload']); | |
| gulp.watch(config.main, ['main', 'reload']); | |
| browserSync({ | |
| server: { | |
| baseDir: config.path.dest | |
| }, | |
| open: true, | |
| notify: false | |
| }); | |
| }); | |
| /** | |
| * Default: Only builds everything once | |
| */ | |
| gulp.task('default', ['clean', 'tsc', 'main', 'vendor']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment