Heat the grill to high. Lay the pepper quarters skin-side up on a baking tray and grill until the skins are black and charred. Tip into a bowl, cover and leave to cool. Peel the charred skin off the peppers, then cut into strips, and toss back in the juices collected in the bowl. Tie the basil stalks and thyme sprig together using kitchen string and set aside.
Heat the oven to 160C/140C fan/ gas 4. Heat the olive oil in a flameproof casserole dish and fry the courgettes and aubergine for 15 mins until nicely browned. You may need to do this in batches, adding more oil to the pan as needed so the pan is never dry.
Scoop the veg out of the pan and set aside. Add a drizzle more oil, tip in the onion and cook for another 15 mins until softened and starting to brown. Add the garlic and leave to sizzle for a moment. Scatter with sugar, then leave for a minute to caramelise and splash in the vinegar. Stir in the cooked vegetables along with the pepper juice, season generously, pour over the cans of tomatoes and bring everything to a simmer.
Nestle in the herbs, cover the dish and transfer to the oven for 1 hr. Remove the lid and give it another 30 mins until everything is cooked down and jammy. Leave the ratatouille to cool until just warm, then stir through most of the basil leaves and the extra virgin olive oil. Scatter with the rest of the basil and serve with griddled sourdough.