diff --git a/rollup.config.js b/rollup.config.js index 75cd52e..ccfe5c4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,6 +2,26 @@ import { defineConfig } from "rollup"; import nodeResolve from "@rollup/plugin-node-resolve"; import sucrase from "@rollup/plugin-sucrase"; import terser from "@rollup/plugin-terser"; +import { createHash } from "node:crypto"; + +function printHash() { + return { + name: "hash-output-plugin", + async writeBundle(options, bundle) { + for (const [fileName, assetInfo] of Object.entries(bundle)) { + if (assetInfo.code) { + try { + const data = Buffer.from(assetInfo.code) + const hash = createHash("sha3-512").update(data).digest("hex"); + console.log(`SHA3-512 for ${assetInfo.fileName}: ${hash}`); + } catch (err) { + console.error(`Error hashing ${fileName}:`, err.message); + } + } + } + }, + }; +} export default defineConfig([ { @@ -23,6 +43,7 @@ export default defineConfig([ exclude: ["node_modules/**"], transforms: ["typescript"], }), + printHash(), ], }, { @@ -47,6 +68,7 @@ export default defineConfig([ transforms: ["typescript"], }), terser(), + printHash(), ], }, { @@ -63,6 +85,7 @@ export default defineConfig([ exclude: ["node_modules/**"], transforms: ["typescript"], }), + printHash(), ], }, { @@ -81,6 +104,7 @@ export default defineConfig([ transforms: ["typescript"], }), terser(), + printHash(), ], }, ]);