From 3655915fc18fe71fc8aba8c2d673ae80436d5360 Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Fri, 26 Sep 2025 18:21:51 +1200 Subject: [PATCH] Print hash of files when building --- rollup.config.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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(), ], }, ]);