Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tailwind, Windi, Twind, UnoCSS or similar Atomic CSS support #89

Closed
heinthanth opened this issue Apr 24, 2022 · 7 comments
Closed

Tailwind, Windi, Twind, UnoCSS or similar Atomic CSS support #89

heinthanth opened this issue Apr 24, 2022 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@heinthanth
Copy link

Hii,

This is feature request. Currently, I can import unocss/runtime script tag and generate CSS only the fly. But this is client side generation.

Screen Shot 2022-04-24 at 8 55 42 PM

Can we have atomic CSS support with a nice SSR?

@mashaal mashaal added enhancement New feature or request help wanted Extra attention is needed labels Apr 24, 2022
@mashaal
Copy link
Member

mashaal commented Apr 24, 2022

Better CSS tooling has been on our list for a while. Ideally, we would love to have 1st class support for CSS module import assertions. Posting some links for reference...

denoland/deno#11961
denoland/deno#13898
https://web.dev/css-module-scripts
https://github.com/guybedford/es-module-shims#css-modules

But these may still be a while off -- we can explore other options in the interim, unocss looks great.

@mashaal
Copy link
Member

mashaal commented Apr 27, 2022

This one just came across my desk: https://open-props.style

This wouldn't require any changes to core to work, if anyone is interested

@mashaal mashaal added the question Further information is requested label Apr 29, 2022
@cdoremus
Copy link
Contributor

cdoremus commented Apr 29, 2022

What about -- as a start -- to just minify the static CSS before it is deployed to prod. Use something like https://github.com/postcss/postcss-deno with a minification utility.

@deckchairlabs
Copy link
Member

What about -- as a start -- to just minify the static CSS before it is deployed to prod. Use something like https://github.com/postcss/postcss-deno with a minification utility.

Yeah this is a good idea, although I'd recommend using https://github.com/parcel-bundler/parcel-css

@heinthanth
Copy link
Author

Yeah ... currently, only way is to write CSS separately, build it and import in Ultra.

@nnmrts
Copy link
Contributor

nnmrts commented Aug 10, 2022

In case anyone is interested, here is how I implemented postcss support and it's surprisingly easy and performant (works with the current [email protected] version):

src folder structure:

api/
	style.css.js
app.jsx
style.pcss

style.css.js:

import postcss from "postcss";
import postcssNestedProps from "postcss-nested-props";
import postcssNesting from "postcss-nesting";
import postcssHasPseudo from "postcss-has-pseudo";

const {
	readTextFile
} = Deno;

export default async () => {
	const cssFilePath = "./src/style.pcss";

	const cssText = await readTextFile(cssFilePath);

	const output = (await postcss([
		postcssNestedProps,
		postcssNesting,
		postcssHasPseudo
	]).process(cssText, { from: cssFilePath, map: true })).css;

	return new Response(output, {
		headers: new Headers({
			"content-type": "text/css; charset=utf-8"
		})
	});
};

app.jsx:

import React from "react";
import { SWRConfig } from "swr";
import { Helmet } from "react-helmet";
import { Route, Switch } from "wouter";
import ultraCache from "ultra/cache";

const options = (cache) => ({
  provider: () => ultraCache(cache),
  suspense: true,
});

const Ultra = ({ cache }) => {
  return (
    <SWRConfig value={options(cache)}>
      <Helmet>
        <title>Ultra</title>
        <link rel="stylesheet" href="./api/style.css" />
      </Helmet>
      <main>
        <Switch>
          <Route path="/">
            <h1>@__@</h1>
          </Route>
          <Route>
            <strong>404</strong>
          </Route>
        </Switch>
      </main>
    </SWRConfig>
  );
};

export default Ultra;

my import map includes these postcss modules:

    "postcss": "https://deno.land/x/[email protected]/mod.js",
    "postcss-nested-props": "https://esm.sh/postcss-nested-props?deps=postcss@8",
    "postcss-nesting": "https://cdn.jsdelivr.net/npm/postcss-nesting@10/mod.js",
    "postcss-has-pseudo": "https://esm.sh/css-has-pseudo@3",

@mashaal
Copy link
Member

mashaal commented Aug 23, 2022

Twind, Emotion and Stitches should work in V2

@mashaal mashaal closed this as completed Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants