diff --git a/README.md b/README.md index a83ede3..99ef320 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,16 @@ * npm start * Compiles your files, starts watching files for changes, serves static files to port 9001 * npm run build - * Builds & minifies everything + * Builds everything + +Minification, uglification and other tasks you're expected to run before deploying your product can be made by running the build command with env variable NODE_ENV set to "production" + + NODE_ENV=production npm run build + ## Adding 3rd party libraries +**Note**: If the package you are looking for can be found in NPM it's much easier to install it from there. After installing packages from NPM they can be required without any of the following instructions. + bower install jquery --save Now to use jQuery in your frontend code, you'll need to add jQuery to "browser" and "browserify-shim" sections of your package.json. Your package.json should be something like this: @@ -46,7 +53,7 @@ Now to use jQuery in your frontend code, you'll need to add jQuery to "browser" Now your should be able to require jQuery in your coffee files - $ = require 'jquery' + $ = require 'jquery' ## Development guidelines diff --git a/gulpfile.coffee b/gulpfile.coffee index 807dbd1..0879297 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -18,60 +18,50 @@ plumber = require 'gulp-plumber' prefix = require 'gulp-autoprefixer' reloadServer = lr() -compileCoffee = (debug = false) -> +production = process.env.NODE_ENV is 'production' + +gulp.task 'coffee', -> bundle = watchify('./src/coffee/main.coffee') rebundle = -> - build = bundle.bundle(debug: debug) + build = bundle.bundle(debug: not production) .pipe(source('bundle.js')) - build.pipe(streamify(uglify())) unless debug + build.pipe(streamify(uglify())) if production build .pipe(gulp.dest('./public/js/')) .pipe(livereload(reloadServer)) - bundle.on 'update', rebundle + bundle.on 'update', rebundle unless production rebundle() -compileJade = (debug = false) -> +gulp.task 'jade', -> gulp .src('src/jade/*.jade') - .pipe(jade(pretty: debug)) + .pipe(jade(pretty: not production)) .pipe(gulp.dest('public/')) .pipe livereload(reloadServer) -compileStylus = (debug = false) -> +gulp.task 'stylus', -> styles = gulp .src('src/stylus/style.styl') .pipe(stylus({set: ['include css']})) .pipe(prefix("last 1 version", "> 1%", "ie 8")) - styles.pipe(CSSmin()) unless debug + styles.pipe(CSSmin()) if production styles.pipe(gulp.dest('public/css/')) .pipe livereload reloadServer -copyAssets = (debug = false) -> +gulp.task 'assets', -> gulp .src('src/assets/**/*.*') .pipe gulp.dest 'public/' -# Build tasks -gulp.task "jade-production", -> compileJade() -gulp.task 'stylus-production', ->compileStylus() -gulp.task 'coffee-production', -> compileCoffee() -gulp.task 'assets-production', -> copyAssets() - -# Development tasks -gulp.task "jade", -> compileJade(true) -gulp.task 'stylus', -> compileStylus(true) -gulp.task 'coffee', -> compileCoffee(true) -gulp.task 'assets', -> copyAssets(true) - gulp.task "server", -> staticFiles = new nodeStatic.Server './public' require('http').createServer (req, res) -> @@ -88,5 +78,5 @@ gulp.task "watch", -> gulp.watch "src/stylus/*.styl", ["stylus"] gulp.watch "src/assets/**/*.*", ["assets"] -gulp.task "build", ["coffee-production", "jade-production", "stylus-production", "assets-production"] -gulp.task "default", ["coffee", "jade", "stylus", "assets", "watch", "server"] +gulp.task "build", ["coffee", "jade", "stylus", "assets"] +gulp.task "default", ["build", "watch", "server"]