Preheat your oven to 350°F (175°C). Grease a 9x5-inch loaf pan or line it with parchment paper for easy removal.
In a large mixing bowl, whisk together the flour, sugar, baking powder, baking soda, salt, and shredded coconut until well combined.
In another bowl, mix the crushed pineapple, vegetable oil, eggs, vanilla extract, and almond extract until smooth.
Pour the wet ingredients into the dry ingredients and stir until just combined. If using, fold in the chopped walnuts or pecans. Be careful not to overmix.
Pour the batter into the prepared loaf pan and smooth the top with a spatula.
Bake in the preheated oven for 50-60 minutes, or until a toothpick inserted into the center comes out clean.
Once baked, remove the bread from the oven and let it cool in the pan for about 10 minutes. Then transfer it to a wire rack to cool completely.