aboutsummaryrefslogtreecommitdiff
path: root/gulpfile.js
diff options
context:
space:
mode:
authorIndrajith K L2018-08-12 17:52:54 +0530
committerIndrajith K L2018-08-12 17:52:54 +0530
commit0193315dd52bf763d7b8f570039cd1771b2e725c (patch)
tree1e1b90862c11d7a2e7749789aaf6cb45765114d8 /gulpfile.js
parentdb47cb139e2677fb0d57f7c5fd5198d76ee2ca56 (diff)
downloadjs13kgames-template-0193315dd52bf763d7b8f570039cd1771b2e725c.tar.gz
js13kgames-template-0193315dd52bf763d7b8f570039cd1771b2e725c.tar.bz2
js13kgames-template-0193315dd52bf763d7b8f570039cd1771b2e725c.zip
:arrow_up: :gem:
* Support ES6 * Integrates jsfxr
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js64
1 files changed, 43 insertions, 21 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 68c26f3..0bb7f86 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,56 +1,78 @@
'use strict';
var gulp = require('gulp');
-var browserSync = require('browser-sync').create();
+var browserSync = require('browser-sync');
var uglify = require('gulp-uglify');
-const zip = require('gulp-vinyl-zip').zip;
+var zip = require('gulp-vinyl-zip').zip;
var size = require('gulp-size');
+var runSequence = require('run-sequence');
+let rollup = require('rollup-stream');
+var source = require('vinyl-source-stream');
var libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js'];
+var devLibs = ['./node_modules/jsfxr/jsfxr.js'];
var libFolder = 'libs/';
var outputTemp = 'temp/';
-gulp.task('serve', ['copylibs'], function () {
-
+gulp.task('serve', ['copylibs', 'copylibsDev', 'uglyfy_copy'], function () {
browserSync.init({
- server: './'
+ server: {
+ baseDir: "./"
+ }
});
- gulp.watch("./**/*.js", { cwd: './' },function(){
- gulp.run('uglyfy_copy')
- }).on('change', browserSync.reload);;
+ gulp.watch("src/js/**/*.js", { cwd: './' }, ['uglyfy_copy', 'reload'])
gulp.watch("./**/*.html", { cwd: './' }).on('change', browserSync.reload);
browserSync.watch()
});
+gulp.task('reload', function () {
+ browserSync.reload();
+});
+
+
gulp.task('uglyfy_copy', function () {
- return gulp.src('src/js/*.js')
- .pipe(uglify())
- .pipe(gulp.dest('public/js'));
+ return rollup({
+ "format": "iife",
+ input: './src/js/main.js'
+ })
+ .pipe(source('main.js'))
+ .pipe(gulp.dest('public/js'));
});
gulp.task('copylibs', function () {
return gulp
- .src(libs)
- .pipe(gulp.dest(libFolder))
+ .src(libs)
+ .pipe(gulp.dest(libFolder))
});
-gulp.task('zipFiles',['prepare_dist_folder'], function () {
+gulp.task('copylibsDev', function () {
+ return gulp
+ .src(devLibs)
+ .pipe(uglify())
+ .pipe(gulp.dest(libFolder))
+});
+
+gulp.task('zipFiles', function () {
return gulp.src('temp/**/*.*')
- .pipe(zip('archive.zip'))
- .pipe(gulp.dest('dist'))
- .pipe(size({
- title: '### Final Archive Size => '
- }))
+ .pipe(zip('archive.zip'))
+ .pipe(gulp.dest('dist'))
+ .pipe(size({
+ title: '### Final Archive Size => '
+ }))
});
gulp.task('prepare_dist_folder', function () {
return gulp
- .src(['libs/*','public/**/*.*','index.html'],{base: './'})
- .pipe(gulp.dest(outputTemp))
+ .src(['libs/*', 'public/**/*.*', 'index.html'], { base: './' })
+ .pipe(gulp.dest(outputTemp))
+});
+
+gulp.task('release', function () {
+ runSequence('copylibs', 'copylibsDev', 'uglyfy_copy', 'prepare_dist_folder', 'zipFiles');
});