This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

build: browserify ergänzt

  • Loading branch information...
barbalex committed Sep 10, 2014
1 parent 4855b50 commit 560596ed23782dea70a2e6d34a6bc062f9b9387e
View
@@ -4,6 +4,5 @@
// ".*~$"
// ".*\\.swp$"
// ".*\\.bak$"
"node_modules$"
"gulp-tasks$"
"node_modules$", "gulp-tasks$", "gulpfile.js"
]
View
@@ -0,0 +1,53 @@
/* browserify task
---------------
Bundle javascripty things with browserify!
If the watch task is running, this uses watchify instead
of browserify for faster bundling using caching.
*/
var browserify = require('browserify');
var watchify = require('watchify');
var bundleLogger = require('../vendor/couchapp/_attachments/util/bundleLogger');
var gulp = require('gulp');
var handleErrors = require('../vendor/couchapp/_attachments/util/handleErrors');
var source = require('vinyl-source-stream');
gulp.task('browserify', function() {
var bundler = browserify({
// Required watchify args
cache: {}, packageCache: {}, fullPaths: true,
// Specify the entry point of your app
entries: ['./vendor/couchapp/_attachments/evab.js'],
// Add file extentions to make optional in your requires
extensions: ['.js'],
// Enable source maps!
debug: true
});
var bundle = function() {
// Log when bundling starts
bundleLogger.start();
return bundler
.bundle()
// Report compile errors
.on('error', handleErrors)
// Use vinyl-source-stream to make the
// stream gulp compatible. Specifiy the
// desired output filename here.
.pipe(source('app.js'))
// Specify the output destination
.pipe(gulp.dest('./vendor/couchapp/_attachments/'))
// Log when bundling completes!
.on('end', bundleLogger.end);
};
if(global.isWatching) {
bundler = watchify(bundler);
// Rebundle with watchify on changes.
bundler.on('update', bundle);
}
return bundle();
});
View
@@ -1,6 +1,8 @@
var gulp = require('gulp');
return gulp.task('watch', function() {
gulp.watch(['_attachments/*', 'vendor/couchapp/_attachments/*', '-vendor/couchapp/_attachments/main.js', '-vendor/couchapp/_attachments/main2.js', '-_attachments/style'], ['dev_src_1', 'dev_src_2']);
gulp.watch(['_attachments/*', 'vendor/couchapp/_attachments/*', '-vendor/couchapp/_attachments/main.js', '-vendor/couchapp/_attachments/main2.js', '-vendor/couchapp/_attachments/app.js', '-_attachments/style'], ['dev_src_1', 'dev_src_2']);
gulp.watch(['_attachments/style/*', '-_attachments/style/main.css', '-_attachments/style/evab.min.css'], ['dev_style']);
// browserify soll wissen, das gewatched wird
global.isWatching = true;
});
View
@@ -35,6 +35,10 @@
"gulp-uglify": "~0.3.2",
"gulp-notify": "~1.3.1",
"browserify": "~5.11.1",
"require-dir": "~0.1.0"
"require-dir": "~0.1.0",
"watchify": "~1.0.2",
"vinyl-source-stream": "~1.0.0",
"gulp-util": "~3.0.1",
"pretty-hrtime": "~0.2.1"
}
}
@@ -0,0 +1,21 @@
/* bundleLogger
------------
Provides gulp style logs to the bundle method in browserify.js
*/
var gutil = require('gulp-util');
var prettyHrtime = require('pretty-hrtime');
var startTime;
module.exports = {
start: function() {
startTime = process.hrtime();
gutil.log('Running', gutil.colors.green("'bundle'") + '...');
},
end: function() {
var taskTime = process.hrtime(startTime);
var prettyTime = prettyHrtime(taskTime);
gutil.log('Finished', gutil.colors.green("'bundle'"), 'in', gutil.colors.magenta(prettyTime));
}
};
@@ -0,0 +1,15 @@
var notify = require("gulp-notify");
module.exports = function() {
var args = Array.prototype.slice.call(arguments);
// Send error to notification center with gulp-notify
notify.onError({
title: "Compile Error",
message: "<%= error.message %>"
}).apply(this, args);
// Keep gulp from hanging on this task
this.emit('end');
};

0 comments on commit 560596e

Please sign in to comment.