forked from freshframework/fresh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler.ts
More file actions
23 lines (20 loc) · 742 Bytes
/
compiler.ts
File metadata and controls
23 lines (20 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import twPostcss from "@tailwindcss/postcss";
import postcss from "postcss";
import type { TailwindPluginOptions } from "./types.ts";
import type { ResolvedFreshConfig } from "fresh";
export async function initTailwind(
config: ResolvedFreshConfig,
options: TailwindPluginOptions = {},
): Promise<postcss.Processor> {
const plugins = [
// deno-lint-ignore no-explicit-any
twPostcss(options.postcssOptions) as any,
];
// when in production mode, minify the CSS
if (config.mode === "production" && options.minify !== false) {
const { default: cssnano } = await import("cssnano");
// deno-lint-ignore no-explicit-any
plugins.push(cssnano(options.cssnanoOptions ?? {}) as any);
}
return postcss(plugins);
}