The code that drives the WiFi section on an ESP8266 has to be called every....I'm not sure...every few milliseconds otherwise you get the resets. If you have a while loop that goes on for a long time you will get resets. You need to rewrite without the while loop and let loop do the looping, that's what it's for.
And in answer to your next question there is already enough information on this website in tutorials and answers to similar questions about how to do that. Do some searching for non blocking code and doing several things at the same time.
using the ESP8266 in while() loops etc I found calling
to reset the watchdog timer helps
In that case why not just call yield();which does not only reset the wdt, but also executes any scheduled tasks, making you wifi connection much more reliable.
The wdt reboots the ESP when it hasn't been fed for 2.5secs. delay() calls yield(), and at the end of loop() also yield() is called.
the while loop is dependent on the the result of the analogRead(), but as before if the whole process takes more than 2.5s a wdt-reset will occur. Just add yield(); or possibly add yield() to the stepper library's run() function. Most stepper libraries aren't very good and depend on blocking code, but so far i haven't seen anyone making a proper effort to use timers to do the work. It must be out there though.
++ Karma; // I missed the bit about stepper motor libraries being blocking, probably because I have never used one. Very annoying when I spend a lot of time on here trying to introduce newbies to non blocking code only to find libraries that are blocking.