Skip to content

Instantly share code, notes, and snippets.

@iamandrewluca
Created July 31, 2020 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewluca/5b2045075bd9a2650821b4505b321850 to your computer and use it in GitHub Desktop.
Save iamandrewluca/5b2045075bd9a2650821b4505b321850 to your computer and use it in GitHub Desktop.
const postcss = require("postcss");
const tailwind = require("tailwindcss");
const express = require("express");
const app = express();
app.get("/:configBase64/tailwind.css", async (req, res) => {
const buffer = Buffer.from(req.params.configBase64, "base64");
const config = JSON.parse(buffer.toString("utf-8"));
const baseCSS = `@tailwind base;@tailwind components;@tailwind utilities;`;
const { css } = await postcss([tailwind(config)]).process(baseCSS, {
from: undefined,
});
res.set("Content-Type", "text/css");
res.end(css);
});
app.listen(3000, () => console.log("Serving tailwindcss on port 3000!"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment