Skip to content

Instantly share code, notes, and snippets.

@adi518

adi518/postcssContentHashPlugin.js Secret

Last active Dec 15, 2020
Embed
What would you like to do?
// https://github.com/postcss/postcss-plugin-boilerplate/
const CryptoJS = require('crypto-js');
module.exports = (_opts = {}) => {
return {
postcssPlugin: 'content-hash',
Root(root, _postcss) {
const contentHash = CryptoJS.MD5(root.source.input.css);
root.prepend({ text: `content-hash:${contentHash}` });
},
};
};
module.exports.postcss = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment