PostCSS This plugin extaract CSS classes from file and create JSON file where write all unique classes with unique identificators
const plugin = require('postcss-extract-bemclasses').default;
const options = {
output: 'path/to/file.json' // it`s optional
}
postcss([ plugin(options) ])
See PostCSS docs for examples for your environment.