ce7cb702218693d08ea6d83464d2457c9250027c

This commit is contained in:
ms2k 2026-11-12 20:46:28 +09:00
commit 34c5f8963c

View file

@ -0,0 +1,27 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { defineConfig } from "vite";
export default defineConfig({
base: "/account/",
build: {
target: "es2023",
modulePreload: { polyfill: false },
},
plugins: [{
name: "runtime-licenses",
generateBundle() {
const packages = new Map<string, string>();
for (const id of this.getModuleIds()) {
const root = id.match(/(.*\/node_modules\/(?:@[^/]+\/)?[^/]+)/)?.[1];
if (root) {
const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as { name: string; version: string };
packages.set(`${pkg.name}@${pkg.version}`, root);
}
}
const notices = [...packages].sort(([left], [right]) => left.localeCompare(right))
.map(([name, root]) => `${name}\n\n${readFileSync(join(root, "LICENSE"), "utf8")}`);
this.emitFile({ type: "asset", fileName: "licenses.txt", source: notices.join("\n\n") });
},
}],
});