I remember a project that someone had created earlier. It had custom prebuild step that replaced some values in .js files to make dev/stage/prod selection. You had to run it twice to be almost sure it worked. It was using fs.readFile without waiting for a callback.