Nicolas Zozol
Nicolas Zozol

Reputation: 7038

Bundle with browserify programmatically without gulp

It is very easy to bundle with the command line, or using gulp :

     browserifiedSource
    .bundle()
    .pipe(source('./build/index.js'))
    .pipe(gulp.dest('./'));

But this common snippet is using source from vinyl package and gulp. The command line doesn't needed these.

    browserify build/index.js -o dist/index.js

How can I bundle with browserify Javascript Api without gulp or vinyl ?

Upvotes: 0

Views: 573

Answers (1)

cartant
cartant

Reputation: 58400

You can do much the same thing, just pipe to a standard file stream:

const browserify = require('browserify');
const fs = require('fs');

browserify()
    .add('build/index.js')
    .bundle()
    .pipe(fs.createWriteStream('dist/index.js'));

Upvotes: 1

Related Questions