mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-13 08:42:29 +00:00
Print hash of files when building
This commit is contained in:
@@ -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(),
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user