Skip to content

Commit

Permalink
[build] Improved build chain
Browse files Browse the repository at this point in the history
  • Loading branch information
jfresco committed May 8, 2015
1 parent 6763935 commit c12a5de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ ifndef NODE_ENV
NODE_ENV="development"
endif

GULP="./node_modules/.bin/gulp"

run: packages
@echo "Starting application..."
@NODE_PATH=. DEBUG=$(DEBUG) node index.js
@NODE_PATH=. DEBUG=$(DEBUG) $(GULP) build

packages:
@echo "Installing dependencies..."
Expand All @@ -23,5 +24,4 @@ clean:
@rm -rf node_modules components public
@echo "Done.\n"


.PHONY: clean
51 changes: 30 additions & 21 deletions lib/build/js.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
var fs = require('fs');
var gulp = require('gulp');
var util = require('gulp-util');
var browserify = require('browserify');
var babel = require('babelify');
var markdown = require('markdownify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');

gulp
.task('javascript', ['js:build', 'js:lint'])
module.exports = function (settings) {

.task('js:lint', function () {
gulp.src('./lib/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
})

.task('js:build', ['public'], function () {
var production = false;
var b = browserify({
function bundle (opts) {
opts = opts || {};
return browserify({
extensions: ['.md', '.markdown'],
debug: !production
debug: opts.debug
})
.transform(babel)
.transform(markdown)
.add('./lib/boot/boot.js')
.add(settings.clientEntryPoint)
.bundle()
.on('error', function (err) {
console.log(err);
util.log(util.colors.magenta('Browserify bundle failed: ' + err));
this.emit('end');
})
.pipe(source('app.js'))
.pipe(buffer());
}

/*
* Define tasks
*/

gulp
.task('js:lint', function () {
gulp.src('./lib/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
})

// if (!production) b = b.pipe(sourcemaps.init({ loadMaps: true }))
// if (production) b = b.pipe(uglify());
// if (!production) b = b.pipe(sourcemaps.write('./'))
.task('js:build', ['public'], function () {
bundle({ debug: true })
.pipe(gulp.dest(settings.public));
})

b.pipe(gulp.dest('./public/'));
})
.task('js:dist', ['public'], function () {
bundle({ debug: false })
.pipe(uglify())
.pipe(gulp.dest(settings.public))
})
}

0 comments on commit c12a5de

Please sign in to comment.