Ideally, a decoupling capacitor should be as close as you can get it to both the supply terminals of the device. However, when the supply terminals are far away, you must compromise. The underlying goal should be to minimize impedance in the local power supply, which means minimizing trace inductance.
The best solution would probably be a solid ground pour, and then placing the decoupling capacitor near Vcc and tying it to ground with big via or a few small vias.
If you do not have the stackup to do a ground pour, then place the capacitor near Vcc or ground, and connect the capacitor to the far terminal with a relatively wide trace.
Keep in mind, the ESP12 has its own local small value decoupling for handling high-frequency power requirements; the decoupling that you are placing should be designed to supply larger transient supply spikes (for instance, when the radio kicks in). As a result, the frequencies that this decoupling cap must handle are lower, and therefore the impedance requirements are somewhat relaxed (meaning a short length of trace in between cap and module isn't such a huge issue). I have done a design incorporating an ESP12 module, and I used a single 47 uF ceramic cap, placed near the VCC pin of the module. Depending on the nature of your power supply, you may want to use more decoupling, perhaps several 47 uF ceramics in parallel.