posthtml-minify-classnames icon indicating copy to clipboard operation
posthtml-minify-classnames copied to clipboard

Any way to retrieve the mapping between old classnames and new ones ?

Open jeremycos opened this issue 1 year ago • 1 comments

Hello,

is there a way to retrieve the mapping between old css classnames and the new ones ?

Thanks

jeremycos avatar Aug 24 '24 14:08 jeremycos

I looked into this-- you can refactor the process function to do this:

process(tree) {
    const result = this.minifyElements(this.minifyStyles(tree));    
    tree.messages.push({
      type: 'info',
      map: this.classMap,
      from: 'posthtml-minify-classnames'
    });
    return result;
}

Then, you can read the message in the result:

const result = await posthtml(posthtmlPlugins).process(html);
const index = result.messages.findIndex(message => message.from === 'posthtml-minify-classnames');
console.log(result.messages[index]);

jhned avatar Jun 02 '25 19:06 jhned