There are some third-party tools that can do this, but my question is, what’s the advantage? Even if you cut the file size in half, the difference would be virtually imperceptible on a 4G or broadband connection.
The last BSS website I built scored 98 Performance on Lighthouse using a locally hosted version of bootstrap.min.css which showed a transfer size of 47,961 bytes. Lighthouse suggested I could save 200 ms by removing unused CSS, but looking at the waterfall, the file downloaded in just over 100 ms second, so Lighthouse is hallucinating with its 200 ms estimate. If I used a CDN, I’d probably score 100. Again, an imperceptible difference.
You might want to take a look at this thread, where we discussed this subject three years ago. Take particular note of Martin’s answer…