Preheat the oven to 350°F (175°C). Line a baking sheet with parchment paper.
Whisk together flour, baking soda, and salt in a medium bowl.
In a large mixing bowl, beat the butter and sugar until light and fluffy.
Add the egg and vanilla extract, mixing until well combined.
Fold in the well-drained crushed pineapple.
Gradually add dry ingredients to the wet mixture and mix until incorporated.
If using, stir in shredded coconut.
Drop spoonfuls of dough onto the baking sheet, spacing them 2 inches apart.
Bake for 10–12 minutes or until the edges are golden.
Let cool on the sheet for 5 minutes, then transfer to a wire rack to cool completely.