From 4b2449c1ddf483a748acd10b90a2fb9f3b78f3fa Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Fri, 19 Aug 2022 21:19:09 +0100 Subject: [PATCH] release 0.3.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 2 +- readme.md | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a4a1a4..cfc17fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "stailwc" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "itertools", diff --git a/Cargo.toml b/Cargo.toml index 3482ba4..17ba87b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "stailwc" -version = "0.3.0" +version = "0.3.1" [lib] crate-type = ["cdylib"] diff --git a/package.json b/package.json index de34f0f..61c8ea3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stailwc", - "version": "0.3.0", + "version": "0.3.1", "description": "An experimental transpiler to bring tailwind macros to SWC rocket", "author": "arlyon@me.com", "license": "ISC", diff --git a/readme.md b/readme.md index 1ec6b21..9ed2790 100644 --- a/readme.md +++ b/readme.md @@ -13,15 +13,46 @@ performing considerably better than babel-based alternatives. > yarn add stailwc ``` +Currently the setup process is a little bit convoluted, but it +will be cleaned up in the future, once we determine the best +way to package this. Place the following in your next.config.js: + `next.config.js` ```js +const initStailwc = () => { + const resolveConfig = require("tailwindcss/resolveConfig"); + const defaultConfig = require("tailwindcss/defaultConfig"); + const override = require("./tailwind.config"); + + const config = resolveConfig(override, defaultConfig); + + config.theme.colors = Object.entries(config.theme.colors) + .flatMap(([k, v]) => { + if (typeof v === "object") { + const items = Object.entries(v).map(([k2, v2]) => [k + "-" + k2, v2]); + return items; + } else { + return [[k, v]]; + } + }) + .reduce( + (acc, [k, v]) => ({ + ...acc, + [k]: v, + }), + {} + ); + + return ["stailwc", { config }]; +}; + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, swcMinify: true, experimental: { - swcPlugins: [["stailwc", {}]], + swcPlugins: [initStailwc()], }, compiler: { emotion: true,