import Postcss from "postcss"; import { readAssetManifest } from "../hash.js"; export default (opts: any = {}): Postcss.Plugin => { return { postcssPlugin: "postcss-hashes", Once() { opts._mappings = readAssetManifest(); }, Declaration(decl: Postcss.Declaration) { decl.value = decl.value.replace(/url\("([^"]+)"\)/, (v, url) => { if (opts._mappings.hasOwnProperty(url)) { return v.replace(url, opts._mappings[url]); } return v; }); }, }; }; export const postcss = true;