Limitations

Unfortunately, Ammolite has some limitations.

Declaration

All static APIs must be declared at the top level. Nested declarations inside other functions will not work.

Invalid
Valid
// ❌ This does not work

import { style, merge } from "ammolite";

const component = (): HTMLDivElement => {
    // static
    const containerA: string = style({
        backgroundColor: "black",
        width: 400,
        height: 400,
    });

    // static
    const containerB: string = style({
        backgroundColor: "white",
    });

    // dynamic
    const container: string = merge(containerA, containerB);

    const el: HTMLDivElement = document.createElement("div");
    el.className = container;

    return el;
};

document.body.append(component());

Support for SvelteKit

Vite plugin does not support SvelteKit out of the box.

Therefore, @ammolite/postcss is required to work with SvelteKit.

For more information, please refer to Vite plugin API (transformIndexHtml).