2026-04-03 20:07:14 -07:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import { resolve } from "path";
|
|
|
|
|
import fs from "fs";
|
|
|
|
|
|
|
|
|
|
function getInputs() {
|
|
|
|
|
const inputs = {
|
|
|
|
|
main: resolve(__dirname, "index.html"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const entries = fs.readdirSync(__dirname, { withFileTypes: true });
|
|
|
|
|
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
if (
|
|
|
|
|
entry.isDirectory() &&
|
|
|
|
|
entry.name !== "node_modules" &&
|
|
|
|
|
entry.name !== "dist" &&
|
|
|
|
|
!entry.name.startsWith(".")
|
|
|
|
|
) {
|
|
|
|
|
const indexPath = resolve(__dirname, entry.name, "index.html");
|
|
|
|
|
if (fs.existsSync(indexPath)) {
|
|
|
|
|
inputs[entry.name] = indexPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return inputs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-05-19 22:48:39 -07:00
|
|
|
plugins: [
|
|
|
|
|
{
|
|
|
|
|
name: "copy-pdfs",
|
|
|
|
|
writeBundle() {
|
|
|
|
|
const entries = fs.readdirSync(__dirname, { withFileTypes: true });
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
if (
|
|
|
|
|
entry.isDirectory() &&
|
|
|
|
|
entry.name !== "node_modules" &&
|
|
|
|
|
entry.name !== "dist" &&
|
|
|
|
|
!entry.name.startsWith(".")
|
|
|
|
|
) {
|
|
|
|
|
const dirPath = resolve(__dirname, entry.name);
|
|
|
|
|
const files = fs.readdirSync(dirPath);
|
|
|
|
|
for (const file of files) {
|
|
|
|
|
if (file.toLowerCase().endsWith(".pdf")) {
|
|
|
|
|
const src = resolve(dirPath, file);
|
|
|
|
|
const destDir = resolve(__dirname, "dist", entry.name);
|
|
|
|
|
const dest = resolve(destDir, file);
|
|
|
|
|
|
|
|
|
|
if (!fs.existsSync(destDir)) {
|
|
|
|
|
fs.mkdirSync(destDir, { recursive: true });
|
|
|
|
|
}
|
|
|
|
|
fs.copyFileSync(src, dest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-04-03 20:07:14 -07:00
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
input: getInputs(),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|