UNPKG

@maizzle/framework

Version:

Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.

57 lines (56 loc) 1.53 kB
import { isLaravel } from "./utils/detect.js"; //#region src/plugin.ts /** * Maizzle Vite plugin for use inside an existing Vite project. * * - During `vite dev`: starts a separate Maizzle dev server on its own port * - During `vite build`: builds email templates alongside the host app * * Does NOT inject Vue, Tailwind, or any other plugins into the host's pipeline. * The host app manages its own stack. Maizzle runs in its own process. */ function maizzle(configInput) { let maizzleServer = null; if (isLaravel()) { const existing = configInput?.components?.source; const laravelComponentDir = "resources/js/components/email"; if (!existing) configInput = { ...configInput, components: { ...configInput?.components, source: [laravelComponentDir] } }; } return [{ name: "maizzle", async configureServer(hostServer) { if (maizzleServer) { await maizzleServer.close(); maizzleServer = null; } const { serve } = await import("./serve.js"); maizzleServer = await serve({ config: configInput }); hostServer.httpServer?.on("close", async () => { if (maizzleServer) { await maizzleServer.close(); maizzleServer = null; } }); }, async closeBundle() { if (this.meta.watchMode) return; const { build } = await import("./build.js"); await build(configInput); }, async buildEnd() { if (maizzleServer) { await maizzleServer.close(); maizzleServer = null; } } }]; } //#endregion export { maizzle }; //# sourceMappingURL=plugin.js.map