Thanks for such an amazing article it helped me get my css from 150kb to 15kb.
I noticed you are using
const componentName = resourcePath.split('/').slice(-2, -1)
But for my purposes were solved using (code below) since a lot of my component names were same and some were written in css
const componentName = path.win32.parse(resourcePath).base