forked from denoland/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtailwind.ts
35 lines (29 loc) · 955 Bytes
/
tailwind.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import tw from "tailwindcss";
import postcss from "postcss";
import autoprefixer from "autoprefixer";
import Site from "lume/core/site.ts";
export interface TailwindOptions {
autoprefixer?: autoprefixer.Options;
options: tw.Config;
}
export default function (options: TailwindOptions) {
const extensions = [".css"];
return (site: Site) => {
// Setup PostCSS process pipeline with TailwindCSS + autoprefixer
const processor = postcss([
tw(options.options),
// deno-lint-ignore no-explicit-any
autoprefixer(options.autoprefixer) as any,
]);
site.loadAssets(extensions);
site.process(extensions, async (pages) => {
// Process all CSS files which tends to be fast enough
await Promise.all(pages.map(async (page) => {
const result = await processor.process(page.content!, {
from: page.src.entry?.src,
});
page.content = result.content;
}));
});
};
}