diff --git a/gulpfile.coffee b/gulpfile.coffee index f866da0..4bf4d74 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -1,17 +1,19 @@ -path = require 'path' +browserify = require 'browserify' +chalk = require 'chalk' +CSSmin = require 'gulp-minify-css' +ecstatic = require 'ecstatic' gulp = require 'gulp' gutil = require 'gulp-util' jade = require 'gulp-jade' -stylus = require 'gulp-stylus' -CSSmin = require 'gulp-minify-css' -browserify = require 'browserify' -watchify = require 'watchify' +livereload = require 'gulp-livereload' +path = require 'path' +prefix = require 'gulp-autoprefixer' +prettyTime = require 'pretty-hrtime' source = require 'vinyl-source-stream' streamify = require 'gulp-streamify' +stylus = require 'gulp-stylus' uglify = require 'gulp-uglify' -ecstatic = require 'ecstatic' -livereload = require 'gulp-livereload' -prefix = require 'gulp-autoprefixer' +watchify = require 'watchify' production = process.env.NODE_ENV is 'production' @@ -43,8 +45,9 @@ gulp.task 'scripts', -> bundle = browserify entries: [paths.scripts.source] extensions: ['.coffee'] + debug: not production - build = bundle.bundle(debug: not production) + build = bundle.bundle() .on 'error', handleError .pipe source paths.scripts.filename @@ -60,7 +63,7 @@ gulp.task 'templates', -> .on 'error', handleError .pipe gulp.dest paths.templates.destination - pipeline = pipeline.pipe livereload() unless production + pipeline = pipeline.pipe livereload(auto: false) unless production pipeline @@ -75,7 +78,7 @@ gulp.task 'styles', -> styles = styles.pipe(CSSmin()) if production styles = styles.pipe gulp.dest paths.styles.destination - styles = styles.pipe livereload() unless production + styles = styles.pipe livereload(auto: false) unless production styles gulp.task 'assets', -> @@ -85,22 +88,28 @@ gulp.task 'assets', -> gulp.task 'server', -> require('http') - .createServer ecstatic root: __dirname + '/public' + .createServer ecstatic root: path.join(__dirname, 'public') .listen 9001 -gulp.task "watch", -> +gulp.task 'watch', -> livereload.listen() gulp.watch paths.templates.watch, ['templates'] gulp.watch paths.styles.watch, ['styles'] gulp.watch paths.assets.watch, ['assets'] - bundle = watchify + bundle = watchify browserify entries: [paths.scripts.source] extensions: ['.coffee'] + debug: not production + cache: {} + packageCache: {} + fullPaths: true bundle.on 'update', -> - build = bundle.bundle(debug: not production) + gutil.log "Starting '#{chalk.cyan 'rebundle'}'..." + start = process.hrtime() + build = bundle.bundle() .on 'error', handleError .pipe source paths.scripts.filename @@ -108,8 +117,12 @@ gulp.task "watch", -> build .pipe gulp.dest paths.scripts.destination .pipe(livereload()) + gutil.log "Finished '#{chalk.cyan 'rebundle'}' after #{chalk.magenta prettyTime process.hrtime start}" .emit 'update' -gulp.task "build", ['scripts', 'templates', 'styles', 'assets'] -gulp.task "default", ["build", "watch", "server"] +gulp.task 'no-js', ['templates', 'styles', 'assets'] +gulp.task 'build', ['scripts', 'no-js'] +# scripts and watch conflict and will produce invalid js upon first run +# which is why the no-js task exists. +gulp.task 'default', ['watch', 'no-js', 'server'] diff --git a/package.json b/package.json index d6df7f5..84e6e33 100644 --- a/package.json +++ b/package.json @@ -16,31 +16,34 @@ "template" ], "dependencies": { - "coffee-script": "~1.7.1" + "coffee-script": "~1.8.0" }, "devDependencies": { - "gulp-uglify": "~0.1.0", - "gulp-util": "~2.2.17", - "gulp-stylus": "1.3.3", - "gulp-jade": "~0.6.0", - "gulp-livereload": "~2.1.0", "bower": "~1.3.5", - "gulp-autoprefixer": "0.0.7", - "browserify": "~4.1.11", - "gulp-streamify": "0.0.5", - "vinyl-source-stream": "~0.1.1", + "browserify": "~6.1.0", + "browserify-shim": "~3.8.0", + "chalk": "~0.5.1", "coffeeify": "~0.7.0", + "deamdify": "^0.1.1", + "debowerify": "~0.9.1", + "ecstatic": "~0.5.3", + "gulp": "~3.8.1", + "gulp-autoprefixer": "1.0.1", + "gulp-jade": "~0.9.0", + "gulp-livereload": "~2.1.0", + "gulp-minify-css": "~0.3.5", + "gulp-streamify": "0.0.5", + "gulp-stylus": "1.3.3", + "gulp-uglify": "~1.0.1", + "gulp-util": "~3.0.1", "karma": "~0.12.21", - "karma-jasmine": "~0.1.5", "karma-chrome-launcher": "~0.1.4", + "karma-cli": "0.0.4", "karma-coffee-preprocessor": "~0.2.1", - "gulp": "~3.8.1", - "watchify": "~0.10.2", - "ecstatic": "~0.5.3", - "gulp-minify-css": "~0.3.5", - "deamdify": "^0.1.1", - "debowerify": "~0.8.2", - "browserify-shim": "~3.8.0" + "karma-jasmine": "~0.2.2", + "pretty-hrtime": "~0.2.2", + "vinyl-source-stream": "~1.0.0", + "watchify": "~2.0.0" }, "browser": {}, "browserify-shim": {},