Skip to content

Instantly share code, notes, and snippets.

@thinkofher
Created August 18, 2024 12:56
Show Gist options
  • Select an option

  • Save thinkofher/2f6e145f57c220ed6cef3e5aeac03a48 to your computer and use it in GitHub Desktop.

Select an option

Save thinkofher/2f6e145f57c220ed6cef3e5aeac03a48 to your computer and use it in GitHub Desktop.
Tailwind in Deno
@tailwind base;
@tailwind components;
@tailwind utilities;
import { parse } from "https://deno.land/std@0.224.0/flags/mod.ts";
import { expandGlob } from "https://deno.land/std@0.224.0/fs/mod.ts";
import tailwind from "npm:tailwindcss@3.4.10";
import postcss from "npm:postcss@8.4.41";
import autoprefixer from "npm:autoprefixer@10.4.20";
import cssnanoPlugin from "npm:cssnano@7.0.5";
import * as typography from "npm:@tailwindcss/typography@0.5.14";
import {
dynamicIconsPlugin,
iconsPlugin,
} from "npm:@egoist/tailwindcss-icons@1.8.1";
import "npm:@iconify/json@2.2.237";
const cwd = new URL(".", import.meta.url);
const target = new URL("./out.css", cwd);
const stylesFile = new URL("./tailwind.css", cwd);
async function tailwindRun() {
const twConfig = {
content: ["./**/*.go"],
plugins: [
typography,
iconsPlugin(),
dynamicIconsPlugin(),
],
};
const styles = await Deno.readTextFile(stylesFile);
const result = await postcss([
tailwind(twConfig),
autoprefixer(),
cssnanoPlugin({ preset: "default" }),
]).process(styles, { from: undefined });
await Deno.writeTextFile(target, result.css);
}
await tailwindRun();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment