A browserify transform that lets you require() text files.
Why
brfs is great for when you need to write javascript that will work both in node and the browser. If you're targeting only the browser though, brfs tends to be a lot of typing and personally I always forget to utf-8 decode the buffer it returns!
How
Require some text files in your browser app:
var html = require('./index.html');console.log(html);
then build it using the browserify CLI:
browserify -t [ txtify2 -e html ] client.js > build.js
or via the API:
var b = browserify(__dirname + '/client.js');b.transform('txtify2', { extensions: [ 'html' ] });b.bundle(function(err, src) { console.log(src) });
This work is free. You can redistribute it and/or modify it under the
terms of the WTFPL.
No Warranty. The Software is provided "as is" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.