Files
notification-elements-demo/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs
Giuliano Silvestro 5d0c9ec7eb Initial commit: notification-elements-demo app
Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 21:49:19 +10:00

47 lines
1.5 KiB
JavaScript

import path from 'node:path';
import { promises } from 'node:fs';
const defaultCacheDir = "node_modules/.vite";
function viteBasicSslPlugin(options) {
return {
name: "vite:basic-ssl",
async configResolved(config) {
const certificate = await getCertificate(
options?.certDir ?? (config.cacheDir ?? defaultCacheDir) + "/basic-ssl",
options?.name,
options?.domains
);
const https = () => ({ cert: certificate, key: certificate });
if (config.server.https === void 0 || !!config.server.https) {
config.server.https = Object.assign({}, config.server.https, https());
}
if (config.preview.https === void 0 || !!config.preview.https) {
config.preview.https = Object.assign({}, config.preview.https, https());
}
}
};
}
async function getCertificate(cacheDir, name, domains) {
const cachePath = path.join(cacheDir, "_cert.pem");
try {
const [stat, content] = await Promise.all([
promises.stat(cachePath),
promises.readFile(cachePath, "utf8")
]);
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1e3) {
throw new Error("cache is outdated.");
}
return content;
} catch {
const content = (await import('./chunks/certificate.mjs')).createCertificate(
name,
domains
);
promises.mkdir(cacheDir, { recursive: true }).then(() => promises.writeFile(cachePath, content)).catch(() => {
});
return content;
}
}
export { viteBasicSslPlugin as default, getCertificate };