For eBooks you can write it in any editor you want - word, pages, it doesn't really matter. Then just export to ePub and you're done.
For my published books I want ultimate control over the layout, so I write them in LaTeX to get the pdf to go to the printer. To get it into an eBook I use pandoc to convert them. I wrote a script that does it for me, and massages the resulting ePub until it's exactly what I want.
My published books is about 70,000 words. Writing it didn't actually take very long (a few hundred hours I guess), but then I probably spent at least that much time again editing and revising multiple draft rounds.