In a large pot, melt the butter and heat the olive oil over medium-low heat. Add the sliced onions and cook, stirring occasionally, for about 30-40 minutes until they are caramelized and golden brown.
Sprinkle the sugar over the onions to aid in the caramelization process.
Pour in the wine (if using) to deglaze the pot, scraping up any flavorful bits from the bottom. Let the wine simmer for a few minutes until reduced.
Add the vegetable broth and water to the pot. Add salt and black pepper according to your tastepreferences .Bring the mixture to a gentle simmer and let it cook for about 20-30 minutes toallow the flavors to meld.
While the soup simmers, preheat the oven to 350°F (175°C). Toast the slices of baguette or French bread in the oven until they are slightly crispy.
Ladle the soup into oven-safe bowls. Place a slice or two of toasted bread on top of each bowl of soup.
Sprinkle a generous amount of grated Gruyère or Emmental cheese over the bread slices.
Place the bowls on a baking sheet and broil in the oven until the cheeseis melted, bubbly, and slightly golden.
Carefully remove the bowls from the oven and let them cool for a minutebefore serving.
Garnish each bowl with fresh thyme leaves.