Begin by slicing the onions thinly using a knife. Aim for even slices to ensure even cooking.
In a large pot or Dutch oven, melt the butter and olive oil over medium heat. Add the sliced onions, salt, and sugar. Cook, stirring frequently, for about 25-30 minutes, until the onions are caramelized and golden brown.
Add the thyme, bay leaf, and freshly ground black pepper to the caramelized onions. Stir well.
Pour in the beef broth and white wine (if using). Bring the mixture to a simmer, then reduce the heat to low. Let it cook for an additional 15 minutes.
While the soup simmers, preheat your oven to 375°F (190°C). Arrange the slices of French bread on a baking sheet. Toast them in the oven for about 10 minutes, until golden and crispy.
Remove the bay leaf from the soup. Ladle the soup into oven-safe bowls or crocks. Place a slice of toasted French bread on top of each bowl, then generously sprinkle with grated Gruyère cheese.
Place the bowls on the baking sheet and transfer them to the oven. Bake for about 10-15 minutes or until the cheese is bubbling and golden.
Carefully remove the bowls from the oven and serve hot.