Last active
March 15, 2017 16:11
-
-
Save ryanhallcs/a85eac4586beec25799c89b888787a4e to your computer and use it in GitHub Desktop.
This file contains 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
var gulp = require("gulp"); | |
var browserify = require("browserify"); | |
var source = require('vinyl-source-stream'); | |
var tsify = require("tsify"); | |
var browserSync = require('browser-sync').create(); | |
var del = require('del'); | |
var paths = { | |
pages: ['src/**/*.html'], | |
assets: ['assets/**/*.png'], | |
vendor: ['vendor/**/*.js'] | |
}; | |
// for now we are going to have to run gulp clean manually | |
gulp.task('clean', function(cb) { | |
return del(['built/**'], function(err) { | |
cb(err); | |
}); | |
}); | |
gulp.task('copy-pages', function() { | |
return gulp.src(paths.pages) | |
.pipe(gulp.dest("built")); | |
}); | |
gulp.task("copy-assets", function () { | |
return gulp.src(paths.assets) | |
.pipe(gulp.dest("built/assets")); | |
}); | |
gulp.task("copy-vendor", function () { | |
return gulp.src(paths.vendor) | |
.pipe(gulp.dest("built/vendor")); | |
}); | |
gulp.task("default", ["copy-pages", "copy-assets", "copy-vendor"], function () { | |
return browserify({ | |
basedir: 'src/lib', | |
debug: true, | |
entries: ['./game.ts'], | |
cache: {}, | |
packageCache: {} | |
}) | |
.plugin(tsify) | |
.bundle() | |
.pipe(source('game.js')) | |
.pipe(gulp.dest("built")); | |
}); | |
gulp.task('watch', ['default'], function(done) { | |
browserSync.reload(); | |
done(); | |
}); | |
gulp.task('serve', ['default'], function () { | |
// Serve files from the root of this project | |
browserSync.init({ | |
server: { | |
baseDir: "built" | |
}, | |
ghostMode: false, | |
online: false | |
}); | |
gulp.watch(["src/**/*.*"], ['watch']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment