Four years ago, Meg Whitman burned the midnight oil raising money for Mitt Romney’s presidential campaign, while Johnvey Hwang volunteered 100-hour weeks building apps for Barack Obama.

But today they’re on the same side.

Eight years after left-leaning technology executives and workers first threw their enthusiastic support to Obama, a new alliance has formed to keep Donald Trump out of the White House.

Whitman, the CEO of Hewlett Packard Enterprise who ran unsuccessfully for California governor six years ago, has for months been among the most outspoken valley titans sounding the alarm about a Trump presidency. Now last week’s official defection to Clinton could set the stage for other high-profile valley Republicans to put their money and their mouths behind a Democrat.

“I think what you’ve seen is that Republicans are beginning to realize that when you step into the voter booth, there’s a difference between holding your nose and choking to death,” said Tucker Bounds, Whitman’s communications director in the 2010 governor’s race.

Valley politics has always been composed of a unique blend of libertarians, traditional liberals and mostly moderate Republicans. But this year — with moderate and Republican technology leaders like Whitman jumping on the stop-Trump bandwagon — Silicon Valley has united behind Clinton more solidly than it has for any previous presidential candidate.

Thanks in part to relaxed campaign finance rules, Clinton is dominating the Silicon Valley money chase. Through June, she had raised more than $31 million from San Jose to San Francisco — far more than Obama’s haul in 2012 or 2008, according to the Crowdpac, a San Francisco firm that tracks political contributions and helps citizens participate in politics. Clinton will return to the Bay Area on Aug. 24 for a fundraiser hosted by Apple CEO Tim Cook.

Trump, meanwhile, raised less than $165,000 across Silicon Valley since jumping into the race more than a year ago.

The New York billionaire’s opposition to free trade and his calls to curtail legal immigration made him a pariah in the Bay Area even before his behavior became increasingly erratic. His lone major technology backer, PayPal co-founder Peter Thiel, still hasn’t donated to his campaign, according to campaign finance reports.

Raising money for Clinton could have been a challenge had the GOP nominated former Florida Gov. Jeb Bush or Sen. Marco Rubio, said Wade Randlett, a veteran valley fundraiser who worked on both Obama campaigns. But with Trump as the opponent, Randlett said, he’s had an easier time collecting checks for Clinton than for any other presidential candidate.

While Romney snagged about 30 percent of Silicon Valley donations four years ago, Randlett said that Trump’s gloom-and-doom convention speech seemed to seal the decision for many wealthy valley donors.

“I had more people email me on their own than I ever had before,” Randlett said. “There was no solicitation, just ‘Where do I send my max-out check? This guy is crazy.’ “

Still, enthusiasm for Clinton’s candidacy appears to run stronger in boardrooms than it does in cubicles.

“I think there’s sort of a grass-roots versus grass-tops dynamic here,” said Matt Mahan, CEO of Brigade, a nonpartisan San Francisco startup working to increase a nonpartisan social media platform built for voters. “The people who are in senior roles are excited about Hillary and raising lots of money.”

But Mahan said quite a few of his employees had an emotional attachment to Vermont Sen. Bernie Sanders and aren’t prepared to put their skills to work on Clinton’s behalf.

Hwang, a 37-year-old San Francisco resident, said he was never a “Bernie Bro,” but like many of his fellow software engineers he isn’t prepared to offer Clinton anything more than his vote.

Volunteering for Obama was “100 percent drinking the Kool-Aid,” Hwang recalled. “The energy was just kind of crazy.”

But having another Clinton in the White House, he said, makes him worry that the country is “starting to stray a little bit from true democracy toward a government that heavily favors those who are connected.”

After losing the technology sector to Obama in the 2008 Democratic primaries, Clinton started her current run for the presidency with support from an impressive stable of Silicon Valley bigwigs, including Facebook’s Sheryl Sandberg, Tesla’s Elon Musk and Steve Jobs’ widow, Laurene Powell Jobs. Eric Schmidt, executive chairman of Alphabet, Google’s parent company, helped a startup that has been providing technology services to the Clinton campaign.

As the primary season progressed, Clinton received a blessing in the form of Trump’s stunning capture of the Republican presidential nomination, as well as a curse in the stiff challenge she faced from Sanders. He polled especially well with millennial males, including many of those who fill the ranks of the valley’s workforce.

The fundraising numbers are somewhat less encouraging for Clinton when Crowdpac drilled down into contributions coming from donors who identified themselves as working for technology companies or having tech-based occupations. Nationwide, she has collected only $3.3 million compared to the $6.2 million Sanders collected. She also trailed Obama’s tech sector contributions in 2008 and 2012.

Clinton did out-raise Sanders among tech professionals in San Francisco, San Mateo and Santa Clara counties, but Sanders had nearly five times as many donors, while she relied heavily on larger donations from technology CEOs and venture capital executives, said Mason Harrison, Crowdpac’s political director.

Clinton is unlikely to ever have the appeal among technology workers that Obama enjoyed, said David Cruise, president of San Francisco Tech Dems.

In his 2008 campaign, Cruise said, Obama mixed youth appeal with charisma and, most importantly, cutting edge data technology that won over the techies.

“There’s definitely a group that feels empowered to help Clinton,” he said. “But even though they’re united, they’re not enthused.”

But Amy Rao, a tech CEO and Clinton bundler from Palo Alto, said her inbox is “full of people who want to help” with their checkbooks and she is expecting even more support now that Whitman is backing Clinton.

“I’m reaching out to all my Republican friends today to write a check for Hillary,” she said. “And it’s happening.”

Whitman, who helped fund efforts to derail Trump’s march to the nomination, came out in support of Clinton on Tuesday, declaring that Trump’s “demagoguery has undermined the fabric of our national character.”

Still, it remains to be seen whether Whitman can actually get a large number of Republicans to openly back Clinton.

“Most of the people I know are kind of reluctantly engaging either Trump or Hillary,” said Jay Kern, a San Francisco venture capitalist who backed Romney four years ago. “I think both of them are quite divisive.”

Kern, a Republican, plans to vote for Libertarian Gary Johnson this year.

But Bounds, who is now president of Sidewire, a nonpartisan political news analysis platform, said Whitman can make a more effective fundraising appeal than Clinton’s typical surrogates.

“When you have a high-profile institutional voice in the Republican Party saying I’m supporting the Democratic nominee because I think the alternative is too dangerous, that’s powerful,” he said. “And it frees Republicans to think about where they stand in this election.”

Contact Matthew Artz at 510-208-6435. Follow him at Twitter.com/Matthew_Artz.