Preheat oven to 350 F. Prepare cupcake pan with liners. Set aside.
In a large bowl whisk together butter, sugar, eggs, milk, rum, and vanilla. Mix until mixture is a pale yellow.
Sift flour and baking powder together. Add to wet mixture a 1/3 at a time, until fully incorporated. Add pineapple to batter and mix until fully incorporated.
Fill each cupcake well 2/3 full. Transfer pan to oven and bake for 20 minutes or until a toothpick inserted into the center emerges clean.
Remove cupcakes from oven and transfer to cooling rack. Allow to cool completely.
Meanwhile, in a large bowl of a stand mixer fitted with the whisk attachment beat softened butter until light and fluffy.
Add powdered sugar, 1 cup at a time, beating buttercream back to fluffy before adding next cup. Add rum and shredded coconut, beating well to incorporate.
Transfer buttercream to piping bag fitted with 1M tip.
Pipe buttercream on cupcakes and sprinkle with coconut shavings.