If desired, caramelize the onions: In a large frying pan, melt the butter over medium heat. Add the sliced onions, sugar, a pinch of salt, and cook, stirring frequently until golden brown and caramelized (about 25-30 minutes). This step enhances the flavor, but can be skipped to simplify the process.
Transfer the caramelized onions (or raw onions if skipped) to the slow cooker. Pour in the beef broth and white wine (if using). Add thyme, bay leaves, salt, and black pepper. Stir well to combine.
Cover and cook on low for 6 hours, or until the onions are tender and flavors are well developed.
During the last 30 minutes of cooking, preheat your oven to 350°F (175°C).
Place the slices of French baguette on a baking sheet. Toast them in the oven for about 10 minutes, or until golden brown.
Remove bay leaves from the soup. Taste and adjust seasoning with additional salt and pepper if needed.
To serve, ladle the soup into bowls, place a slice of toasted baguette on top, and sprinkle generously with Gruyère cheese.
Place bowls under the broiler for 2-3 minutes, until the cheese melts and bubbles. Be careful not to burn the cheese.
Serve hot and enjoy!