Skip to content

Instantly share code, notes, and snippets.

@Raynos Raynos/hack.js
Created Aug 6, 2012

Embed
What would you like to do?
Inject process.env.NODE_ENV into browserify
var code = "var process = require.modules.__browserify_process();\n" +
"process.env.NODE_ENV = '" + process.env.NODE_ENV + "'\n" +
"require.modules.__browserify_process = function () {\n" +
" return process\n" +
"}"
var target = path.join(__dirname, "dummy.js")
bundle.files[target] = {
target: path.join(__dirname, "dummy.js")
, body: code
}
bundle.addEntry(path.join(__dirname, "other.js"), {
body: "require('" + target+ "')"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.