-1

here's my gulp file

var gulp = require('gulp')
var browserify = require('browserify')
var source = require('vinyl-source-stream')
var reactify = require('reactify')
var rename = require('gulp-rename')

gulp.task('js', function() {
    var b = browserify({
        entries: ['./lib/test.js', './lib/app.jsx'],
        transform: [reactify],
        extensions: ['.js','.jsx'],
        debug: false,
        cache: {},
        packageCache: {},
        fullPaths: false
    });

    function build(file) {
        return b
        .external('jquery')
        .plugin('minifyify', {
            map: false
        })
        .bundle()
        .pipe(source('main.js'))
        // Add .min.js to the end of each optimized file
        .pipe(gulp.dest('./js/'));
    };
    build();
});
gulp.task('watch', function() {
    gulp.watch("lib/*.jsx", ["js"])
})
gulp.task('default', ['js', 'watch']);

purpose is to convert all jsx to 1 js file.

Is my gulpfile production ready?

Also, how can I simplify the line: entries: ['./lib/test.js', './lib/app.jsx'],

so that browserify handles all js files in lib/ directory?

Brown Limie
  • 2,249
  • 3
  • 17
  • 18

1 Answers1

0

If you want some pro-level gulpfiles, check https://github.com/greypants/gulp-starter and the 2.0 branch: https://github.com/greypants/gulp-starter/tree/2.0 . The guy has some nice tricks up his sleeves.

Generally speaking, it's a good practice to go the gulp.src way, see this answer: https://stackoverflow.com/a/25319817/5229638

Community
  • 1
  • 1
Wojtek Szkutnik
  • 532
  • 3
  • 6