diff --git a/gulp/tasks/dev.js b/gulp/tasks/dev.js index 39e8028..1ecab42 100644 --- a/gulp/tasks/dev.js +++ b/gulp/tasks/dev.js @@ -2,6 +2,5 @@ runSeq = require('run-sequence'); gulp.task('dev', function (done) { - global.isDev = true; runSeq('build', ['watch'], done); }); diff --git a/gulp/tasks/dev.js b/gulp/tasks/dev.js index 39e8028..1ecab42 100644 --- a/gulp/tasks/dev.js +++ b/gulp/tasks/dev.js @@ -2,6 +2,5 @@ runSeq = require('run-sequence'); gulp.task('dev', function (done) { - global.isDev = true; runSeq('build', ['watch'], done); }); diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js index 1131b16..995a258 100644 --- a/gulp/tasks/scripts.js +++ b/gulp/tasks/scripts.js @@ -2,5 +2,5 @@ bundle = require('../util/bundle'); gulp.task('scripts', function () { - return bundle(global.isDev); + return bundle(); }); diff --git a/gulp/tasks/dev.js b/gulp/tasks/dev.js index 39e8028..1ecab42 100644 --- a/gulp/tasks/dev.js +++ b/gulp/tasks/dev.js @@ -2,6 +2,5 @@ runSeq = require('run-sequence'); gulp.task('dev', function (done) { - global.isDev = true; runSeq('build', ['watch'], done); }); diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js index 1131b16..995a258 100644 --- a/gulp/tasks/scripts.js +++ b/gulp/tasks/scripts.js @@ -2,5 +2,5 @@ bundle = require('../util/bundle'); gulp.task('scripts', function () { - return bundle(global.isDev); + return bundle(); }); diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index ac832d4..17bcbf0 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -7,7 +7,7 @@ gulp.watch(paths.scripts, ['jshint']) .on('change', logChanges); - return bundle.watch(connect.reload, isDev); + return bundle.watch(connect.reload); }); function logChanges(event) { diff --git a/gulp/tasks/dev.js b/gulp/tasks/dev.js index 39e8028..1ecab42 100644 --- a/gulp/tasks/dev.js +++ b/gulp/tasks/dev.js @@ -2,6 +2,5 @@ runSeq = require('run-sequence'); gulp.task('dev', function (done) { - global.isDev = true; runSeq('build', ['watch'], done); }); diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js index 1131b16..995a258 100644 --- a/gulp/tasks/scripts.js +++ b/gulp/tasks/scripts.js @@ -2,5 +2,5 @@ bundle = require('../util/bundle'); gulp.task('scripts', function () { - return bundle(global.isDev); + return bundle(); }); diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index ac832d4..17bcbf0 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -7,7 +7,7 @@ gulp.watch(paths.scripts, ['jshint']) .on('change', logChanges); - return bundle.watch(connect.reload, isDev); + return bundle.watch(connect.reload); }); function logChanges(event) { diff --git a/gulp/util/bundle.js b/gulp/util/bundle.js index 2ea65e5..0ff4e8d 100644 --- a/gulp/util/bundle.js +++ b/gulp/util/bundle.js @@ -1,7 +1,10 @@ var path = require('path'), gulp = require('gulp'), gutil = require('gulp-util'), + uglify = require('gulp-uglify'), + rename = require('gulp-rename'), source = require('vinyl-source-stream'), + buffer = require('vinyl-buffer'), browserify = require('browserify'), watchify = require('watchify'), handleErrors = require('../util/handleErrors'); @@ -11,19 +14,23 @@ .on('error', handleErrors.handler) .pipe(handleErrors()) .pipe(source('pixi.js')) + .pipe(gulp.dest(paths.out)) + .pipe(buffer()) + .pipe(uglify()) + .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest(paths.out)); } -function createBundler(args, debug) { +function createBundler(args) { args = args || {}; - args.debug = debug; + args.debug = true; args.standalone = 'PIXI'; return browserify(paths.jsEntry, args); } -function watch(onUpdate, debug) { - var bundler = watchify(createBundler(watchify.args, debug)); +function watch(onUpdate) { + var bundler = watchify(createBundler(watchify.args)); bundler.on('update', function () { rebundle.call(this).on('end', onUpdate); @@ -32,8 +39,8 @@ return rebundle.call(bundler); } -module.exports = function bundle(debug) { - return rebundle.call(createBundler(null, debug)); +module.exports = function bundle() { + return rebundle.call(createBundler()); }; module.exports.watch = watch; diff --git a/gulp/tasks/dev.js b/gulp/tasks/dev.js index 39e8028..1ecab42 100644 --- a/gulp/tasks/dev.js +++ b/gulp/tasks/dev.js @@ -2,6 +2,5 @@ runSeq = require('run-sequence'); gulp.task('dev', function (done) { - global.isDev = true; runSeq('build', ['watch'], done); }); diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js index 1131b16..995a258 100644 --- a/gulp/tasks/scripts.js +++ b/gulp/tasks/scripts.js @@ -2,5 +2,5 @@ bundle = require('../util/bundle'); gulp.task('scripts', function () { - return bundle(global.isDev); + return bundle(); }); diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index ac832d4..17bcbf0 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -7,7 +7,7 @@ gulp.watch(paths.scripts, ['jshint']) .on('change', logChanges); - return bundle.watch(connect.reload, isDev); + return bundle.watch(connect.reload); }); function logChanges(event) { diff --git a/gulp/util/bundle.js b/gulp/util/bundle.js index 2ea65e5..0ff4e8d 100644 --- a/gulp/util/bundle.js +++ b/gulp/util/bundle.js @@ -1,7 +1,10 @@ var path = require('path'), gulp = require('gulp'), gutil = require('gulp-util'), + uglify = require('gulp-uglify'), + rename = require('gulp-rename'), source = require('vinyl-source-stream'), + buffer = require('vinyl-buffer'), browserify = require('browserify'), watchify = require('watchify'), handleErrors = require('../util/handleErrors'); @@ -11,19 +14,23 @@ .on('error', handleErrors.handler) .pipe(handleErrors()) .pipe(source('pixi.js')) + .pipe(gulp.dest(paths.out)) + .pipe(buffer()) + .pipe(uglify()) + .pipe(rename({ suffix: '.min' })) .pipe(gulp.dest(paths.out)); } -function createBundler(args, debug) { +function createBundler(args) { args = args || {}; - args.debug = debug; + args.debug = true; args.standalone = 'PIXI'; return browserify(paths.jsEntry, args); } -function watch(onUpdate, debug) { - var bundler = watchify(createBundler(watchify.args, debug)); +function watch(onUpdate) { + var bundler = watchify(createBundler(watchify.args)); bundler.on('update', function () { rebundle.call(this).on('end', onUpdate); @@ -32,8 +39,8 @@ return rebundle.call(bundler); } -module.exports = function bundle(debug) { - return rebundle.call(createBundler(null, debug)); +module.exports = function bundle() { + return rebundle.call(createBundler()); }; module.exports.watch = watch; diff --git a/package.json b/package.json index 20e18d5..45e6868 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,8 @@ "gulp": "^3.8.10", "gulp-jshint": "^1.9.0", "gulp-plumber": "^0.6.6", + "gulp-rename": "^1.2.0", + "gulp-uglify": "^1.0.2", "gulp-util": "^3.0.1", "ink-docstrap": "^0.4.12", "jsdoc": "^3.3.0-alpha13", @@ -37,6 +39,7 @@ "mocha": "^2.1.0", "require-dir": "^0.1.0", "run-sequence": "^1.0.2", + "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.0.0", "watchify": "^2.2.1" },