Preheat your oven to 350°F (177°C) and lightly grease a 9×9" baking dish with non-stick spray or line it with a parchment paper. Set it aside.
Add granulated sugar, melted butter or oil (if using oil), eggs and vanilla extract in a large mixing bowl and whisk until everything is well combined, about 2 minutes.
Next add in crushed pineapple (do not drain the juice) and mix until the batter gets smooth and all ingredients are mixed in well.
Now slowly sift dry ingredients (all-purpose flour, baking soda, and salt) into wet in 2-3 additions and gently fold them together using a spatula or wooden spoon after each addition. Continue folding until the dry ingredients are completely incorporated and no streaks of flour remain in the batter. Scrape the sides of bowl as necessary.
Pour the batter into prepared pan and bake for 30-40 minutes in preheated oven or until a toothpick inserted in the center of cake comes out clean.
If you notice that the cake is browning too quickly in oven, cover it with aluminum foil for the last 15 minutes mark. Or once the cake turns light golden brown, you can cover it to prevent it from browning further.
Allow the cake to cool completely before frosting. Keep the frosting refrigerated too until you are ready to frost the cake.