Cumulonimbus are clouds related to storms. Because of its configuration, some electrification mechanisms are produced within this type of clouds which may lead to lightning formation.
While it is true that the mechanisms of electrification and precipitation can interfere between them, they are actually independent mechanisms with local influence. This means that within a specific area of a cloud there can be a build-up of electrical charge enough to make lightning occur whereas precipitation might not yet be in a mature phase or it might be happening in a different area.
Besides, there are other mechanisms which can also cause electrical charge to build up under certain conditions. As a consequence of this electrification, lightning can occur.
Examples of these other mechanisms could be:
- Sandstorms, where friction of sand particles causes electrification
- Volcano eruptions, because of the high temperatures
- Changes in air quality, due to either local or transported air pollution and also to certain ionization processes that develop in mountainous areas or on high structures under the influence of electric fields.
In conclusion: even though lightning under raining conditions is very frequent, it can also occur without any sign of precipitation.