Browserify with require(‘fs’)

If you want to inline file contents from fs.readFileSync() calls, you can use brfs:

var fs = require('fs');
var src = fs.readFileSync(__dirname + '/file.txt');

then do:

browserify -t brfs main.js > bundle.js

and src will be set to the contents of file.txt at compile time.

Leave a Comment