This repository has been archived by the owner on Sep 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Gabriel
committed
Sep 10, 2014
1 parent
4855b50
commit 560596e
Showing
6 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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(); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,6 +1,8 @@ | |||
var gulp = require('gulp'); | var gulp = require('gulp'); | ||
|
|
||
return gulp.task('watch', function() { | 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']); | gulp.watch(['_attachments/style/*', '-_attachments/style/main.css', '-_attachments/style/evab.min.css'], ['dev_style']); | ||
// browserify soll wissen, das gewatched wird | |||
global.isWatching = true; | |||
}); | }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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)); | |||
} | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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'); | |||
}; |