Skip to content

Instantly share code, notes, and snippets.

@sciolist
Created October 9, 2013 23:36
Show Gist options
  • Save sciolist/6910443 to your computer and use it in GitHub Desktop.
Save sciolist/6910443 to your computer and use it in GitHub Desktop.
awful browserify transform to pack in client config.
function packConfiguration() {
var config = require('../../client-config.js');
var clientConfig = 'module.exports=exports=(' + JSON.stringify(config) + ');\n';
var clientTransformFile = require.resolve('../../../../public/media/js/config.js');
return function clientConfigTransform(file) {
if(file !== clientTransformFile) return through();
var data = '';
return through(
function(inp) { data += inp; },
function() {
this.queue(clientConfig + data);
this.queue(null);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment