Skip to content

Instantly share code, notes, and snippets.

@shawninder
Created March 31, 2016 16:21
Show Gist options
  • Save shawninder/24ff053c202aa50379007ab2603ca453 to your computer and use it in GitHub Desktop.
Save shawninder/24ff053c202aa50379007ab2603ca453 to your computer and use it in GitHub Desktop.
Example of streaming data to browserify instead of passing it the path to a file
'use strict'
var Stream = require('stream')
var browserify = require('browserify')
var st = new Stream.Readable()
var js = '// A string of javascript with requires'
st.push(js, 'utf8')
st.push(null)
var b = browserify(st).bundle()
b.on('error', console.error)
var total = ''
b.on('data', (chunk) => {
total += chunk.toString()
})
b.on('end', () => {
console.log('After browserify: ', total)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment