Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Support Watchify #8

Open
Thr1ve opened this issue Jul 31, 2014 · 0 comments
Open

Suggestion: Support Watchify #8

Thr1ve opened this issue Jul 31, 2014 · 0 comments

Comments

@Thr1ve
Copy link

Thr1ve commented Jul 31, 2014

Hello!
Would it be possible to integrate Watchify when using Gulp ?
For instance, https://github.com/greypants/gulp-starter :

his browserify gulp task file:

/*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('../util/bundleLogger');
var gulp         = require('gulp');
var handleErrors = require('../util/handleErrors');
var source       = require('vinyl-source-stream');

gulp.task('browserify', function() {

var bundleMethod = global.isWatching ? watchify : browserify;

var bundler = bundleMethod({
    // Specify the entry point of your app
    entries: ['./src/javascript/app.coffee'],
    // Add file extentions to make optional in your requires
    extensions: ['.coffee', '.hbs'],
    // 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('./build/'))
        // Log when bundling completes!
        .on('end', bundleLogger.end);
};

if(global.isWatching) {
    // Rebundle with watchify on changes.
    bundler.on('update', bundle);
}

return bundle();
});

see also: https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md#fast-browserify-builds-with-watchify

Also:
-Could adding BrowserSync like in greypants' gulp-starter be worth considering?
-It seems like the ".tmp/" equivalent is the "build/" in Gulp. Would it be improper to rename the "tmp" directory to "build" when selecting Gulp?

Trying to get a pull request ready, but I'm a bit new / unexperienced so it may take me awhile...still trying to wrap my head around pretty much everything here...
Please yell at me if I've been improper/ignorant in any way with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant