Both matter. Every type of wood has general characteristics, and every piece of wood within a wood type is unique. For instance, I have three MIJ Jackson DK2 Dinkys, all of them have a Seymour Duncan JB in the bridge with Alder bodies, bolt on Maple necks, and Rosewood fretboards. Each one sounds a little different.
Warmoth.com has a page on their site that describes each wood type. They did a pretty good job with the descriptions and it's worth reading.
When it comes to pickups, it depends on the wood, the construction, and the body shape.
A good example of how construction makes a difference is when you compare a Jackson Dinky (they all have bolt on necks) and a Jackson Soloist (same shape as a Dinky, but with Neck Thru construction). My Soloist has a JB just like my Dinkys do, but when you A/B them, the Soloist is muddy compared to the Dinkys. Why, they both have Alder bodies? Construction. Even though the Soloist has a Maple top and an Ebony fretboard (both of which brighten a guitar's tone) the neck through construction does darken the tone. Whereas the bolt on construction of the Dinkys adds a brightness and extra snap to the tone, most commonly referred to attack. So you have to take all of that into consideration, along with pickup selection, woods, strings, picks, ect.
Here's a few examples of what I prefer for different guitars:
A traditional Les Paul type? I'm probably going to want a hot rodded PAF type pickup, a traditional PAF, or something along the lines of an old school Gibson Dirty Fingers set.
A Mahogany Explorer? A Duncan Screamin' Demon in the bridge and a Full Shred Neck or the afore mentioned Dirty Fingers set.
Strat or Super Strat? Duncan JB in the bridge with whatever I feel like throwing in the other two slots at the moment.
Neck through with an Alder body? That one's still up in the air for me. I have an extra Screamin' Demon that's probably going to go into my Soloist. But I also have been wanting to try a Duncan Jason Becker Perpetual Burn, so I'll probably put it in my KV2 King V (Neck Thru with Alder wings).
Ibanez RG with a Basswood body? What is now known ad the Dimebag Darrel set, a Dimebucker in the bridge and a '59 Bridge in the neck slot. The Dimebucker is too scooped out in other guitars for my tastes, but in a Basswood body with a bolt on Maple neck, its great. The Basswood's warmth and lack of a top end works well with the Dimebucker and the '59 Bridge is just about the perfect pickup to pair with the Dime.
ect.......