Skip to content

Instantly share code, notes, and snippets.

@diverted247
Created August 31, 2015 19:39
Show Gist options
  • Save diverted247/26e614997a476a6f5606 to your computer and use it in GitHub Desktop.
Save diverted247/26e614997a476a6f5606 to your computer and use it in GitHub Desktop.
build task
var gulp = require( 'gulp' );
var ts = require( 'gulp-tsc' );
var connect = require( 'gulp-connect' );
var shell = require( 'gulp-shell' );
var uglify = require( 'gulp-uglify' );
var concat = require( 'gulp-concat' );
var del = require( 'del' );
gulp.task( 'clean' , function( cb ){
del([ './dist' ], cb );
});
gulp.task( 'build' , [ 'clean' ] , function(){
return gulp.src( [ './src/build.d.ts' ] )
.pipe( ts( {
target: 'ES5',
outDir: './dist',
//module: 'amd',
emitError: true,
declaration: false,
removeComments: true
} ) )
.pipe( gulp.dest( './dist' ) );
});
gulp.task( 'minify' , [ 'build' ] , function(){
gulp.src( './dist/**' )
.pipe( uglify() )
.pipe( gulp.dest( './dist/' ) )
});
gulp.task( 'server' , [ 'minify' ] , function () {
connect.server({
port: 8081
})
});
gulp.task( 'watch' , function (){
gulp.watch( 'src/**/*.ts' , [ 'minify' ] )
});
gulp.task( 'browser' , [ 'server' ] , shell.task( [
/^win/.test( require( 'os' ).platform() ) ? 'start http://localhost:8081/' : 'open http://localhost:8081/'
] ) );
gulp.task( 'default' , [ 'browser' ] );
gulp.task( 'dev' , [ 'build' ] );
gulp.task( 'prod' , [ 'minify' ] , function(){
gulp.src( [ './dist/routes.js', './dist/progress.js', './dist/courses.js', './dist/app.js'] )
.pipe( concat( 'course_player.js' ) )
.pipe( gulp.dest( '../../static/js' ) )
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment