It depends on the book, honestly. For a thick, multi-volume epic fantasy, I take years working on the world. Such was the case with The Way of Kings, and a few of the other massive Epics I’m planning. Mistborn had about a year of planning ahead of time.
Some books, however, I write more freely. I almost always spend a few months working on the world before writing; it’s the thing I feel I need best fleshed out. However, it is dangerous as well. Some writers spend all of their time worldbuilding and none of their time writing.
Where do you spend most of your worldbuilding time?
It really depends on the novel. With some I spend a lot of time on areas that in others I don’t spend much time on at all. With every book I spend a serious amount of time on the magic system. That’s consistent—it’s just something I like to do.
I try to focus my energies on areas of worldbuilding important to the conflict and the characters. In Mistborn, the languages weren’t important–I was going to have everyone speaking one language. In Stormlight, language was more important, so I developed the linguistics. (Though that won’t be manifest for a few more books.) For a given book or series I may spend more time on a given aspect.
I’d say the other big aspect that takes a lot of time is characterizing the characters the right way. That takes a lot of work, but I tend to do that during my actual writing period, whereas I spend the planning period focusing on worldbuilding and plot. It’s when I actually sit down to write a chapter that I explore who a character is, and so it’s really hard to pin down timewise which one I spend more time on. And that varies based on the book
I jump around a lot when outlining, and so things kind of grow in one place (maybe character backgrounds) and that sparks me thinking about something in the culture, so I jump over there and work on it for a while. Then over to plot, then back to world.
However, Stormlight is a little different in that I specifically spent months and months doing dedicated worldbuilding for the novel. In this case, I started with the most important setting elements and explored them in a kind of encyclopedia form, then moved on from there.