What happens if the presidential candidate dies before election day?

I did some digging, and this is what I found.

If the candidate dies before the general election, the party's national committee votes on a new candidate in much the same manner as the convention, but without all the fanfare. IOW, there would be a representative from each state with the same number of votes as his state had delegates to the convention. Hopefully, ballots for the general election have not already been printed, or the new candidate's name may not appear on the ballot.

If the candidate dies after the election, but before the Electoral College, electors committed to that candidate are free to elect someone else.

If the candidate dies after the electoral college, but before the inauguration, the VP elect becomes the president elect according to the 20th amendment to the Constitution.