35 lines
992 B
JavaScript
35 lines
992 B
JavaScript
// npm install -g gulp
|
|
// npm install --save-dev browser-sync
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var coffee = require('gulp-coffee');
|
|
var concat = require('gulp-concat');
|
|
var uglify = require('gulp-uglify');
|
|
var sourcemaps = require('gulp-sourcemaps');
|
|
|
|
var browserSync = require('browser-sync');
|
|
var reload = browserSync.reload;
|
|
|
|
|
|
gulp.task('server', function() {
|
|
browserSync({
|
|
server: {
|
|
baseDir: 'public'
|
|
}
|
|
});
|
|
});
|
|
|
|
gulp.task('compile', function() {
|
|
return gulp.src(['src/entities/*.coffee', 'src/tiles/*.coffee', 'src/tools.coffee', 'src/app.coffee', 'src/game.coffee', 'src/hud.coffee'])
|
|
.pipe(sourcemaps.init())
|
|
.pipe(coffee({bare: true}))
|
|
.pipe(concat('app.js'))
|
|
.pipe(sourcemaps.write())
|
|
.pipe(gulp.dest('public'));
|
|
});
|
|
|
|
gulp.task('default', ['server'], function() {
|
|
gulp.watch(['src/**/*.coffee'], ['compile']);
|
|
gulp.watch(['*.html', 'styles.css', 'app.js', 'images/*'], {cwd: 'public'}, reload);
|
|
});
|