Preheat your oven to 350°F (175°C). This temperature is ideal for baking, ensuring an even and fluffy cake. While it heats, spray a 9 x 13-inch baking pan with nonstick cooking spray—this is a crucial step to prevent sticking. If you want to be extra cautious, you can line the pan with parchment paper.
In a large bowl, whisk together 2 cups of all-purpose flour, 2 cups of granulated sugar, 1 teaspoon of baking soda, and ¼ teaspoon of salt. Whisking these dry ingredients thoroughly ensures that the baking soda is evenly distributed, helping the cake rise uniformly.
In a medium bowl, combine 2 eggs, 20 ounces of undrained canned crushed pineapple, 2 teaspoons of pure vanilla extract, and ½ cup of coconut if you're using it. Mix well; the pineapple should be the star here, bringing moisture and sweetness to the batter.
Pour the pineapple mixture into the bowl with the dry ingredients. Stir gently until just combined. Be cautious not to overmix, as this can lead to a dense cake.
Pour the batter into your prepared baking pan. Use a spatula to smooth the top, ensuring it’s even so it bakes nicely.
Place the pan in the preheated oven and bake for 30 to 35 minutes. Keep an eye on it; you’re looking for a golden top with a toothpick inserted into the center coming out clean. If it’s still wet, give it a few more minutes.
Once baked, remove the cake from the oven and let it cool in the pan for about 10 minutes. After this, carefully transfer it to a wire rack to cool completely. Cooling is vital, as it allows the flavors to meld together.
While the cake cools, prepare the cream cheese icing. In a bowl, beat 8 ounces of room temperature cream cheese and 6 tablespoons of room temperature unsalted butter using an electric mixer on medium speed for about 3 to 4 minutes—this should be light and fluffy.
Reduce the mixer speed to low and gradually add in 1 ½ cups of powdered sugar. Mixing slowly at first prevents a sugary cloud in your kitchen!
Add 1 teaspoon of pure vanilla extract and continue beating for an additional 2 to 3 minutes until the mixture is smooth and creamy.
Once your cake is completely cool, spread the cream cheese icing generously over the top. The frosting should be thick and luscious, inviting everyone to dive in!