Preheat your oven to 350°F (175°C) and grease a 9×13 inch baking pan. Line with parchment paper for easier removal if desired.
Whisk together the dry ingredients in a large bowl—flour, sugar, baking powder, baking soda, and salt until well combined.
In a separate bowl, combine the wet ingredients by whisking together the undrained crushed pineapple, eggs, vegetable oil, and vanilla extract until smooth.
Pour the wet mixture into the dry ingredients and stir just until combined. Don’t overmix—a few small lumps are perfectly fine and will create a more tender cake.
Fold in the chopped nuts if using, distributing them evenly throughout the batter.
Transfer the batter to your prepared pan and spread evenly with a spatula. The batter will be relatively thick.
Bake for 35-40 minutes until golden brown and a toothpick inserted in the center comes out clean or with a few moist crumbs.
Allow the cake to cool completely in the pan on a wire rack before frosting, about 1-2 hours.
Prepare the frosting by beating the cream cheese and butter together until smooth and fluffy, about 2-3 minutes on medium speed.
Add the powdered sugar gradually while mixing on low speed, then increase to medium and beat until smooth.
Mix in the vanilla extract until fully incorporated into the frosting.
Spread the frosting evenly over the cooled cake and sprinkle with toasted coconut.
Garnish with fresh pineapple chunks if desired, and refrigerate for at least 30 minutes before serving to allow the frosting to set.