Files
sweet/plugin-tailwindcss/src/mod.ts
T
Luca CasonatoandMarvin Hagemeister 407987589f feat: support fresh projects that are part of a workspace (#2716)
Also a performance improvement & bug fix in the tailwind plugin.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2024-10-17 17:08:24 +02:00

28 lines
756 B
TypeScript

import type { TailwindPluginOptions } from "./types.ts";
import { initTailwind } from "./compiler.ts";
import type { Builder } from "fresh/dev";
import type { App } from "fresh";
export function tailwind<T>(
builder: Builder,
app: App<T>,
options: TailwindPluginOptions = {},
): void {
let processor: ReturnType<typeof initTailwind> | null;
builder.onTransformStaticFile(
{ pluginName: "tailwind", filter: /\.css$/ },
async (args) => {
if (!processor) processor = initTailwind(app.config, options);
const instance = await processor;
const res = await instance.process(args.text, {
from: args.path,
});
return {
content: res.content,
map: res.map?.toString(),
};
},
);
}