Preheat your oven to 350°F (175°C). Grease an 8x8-inch baking dish or line it with parchment paper for easy removal.
In a medium bowl, whisk together the flour, sugar, baking powder, and salt until well combined.
In a separate large bowl, mix the melted butter, egg, and vanilla extract until smooth.
Gradually add the dry ingredients to the wet ingredients, stirring until just combined.
Fold in the crushed pineapple, shredded coconut, and nuts (if using) until evenly distributed.
Pour the batter into the prepared baking dish and spread it out evenly.
Bake for 25-30 minutes or until the edges are golden brown and a toothpick inserted in the center comes out clean.
Allow the bars to cool in the pan for about 10 minutes, then transfer them to a wire rack to cool completely before cutting into squares.