-
Notifications
You must be signed in to change notification settings - Fork 166
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
Support for Tailwind CSS #42
Comments
@yiss Yeah, there isn't an official way to use PostCSS with Deno but @ije created a CDN which converts NPM packages to Deno compatible packages. I think Aleph already uses that but I don't think it is possible to configure that. Once configuration is allowed, it would probably pretty simple to use Tailwind. |
@yiss, sorry i'm not user of tailwind, you can try to import tailwind via CDN: // app.tsx
import 'https://esm.sh/tailwindcss/dist/tailwind.min.css' but this does not support tailwind's build features, likes tree-shaking, theme, directives, etc. |
as @shadowtime2000 mentioned, aleph support postcss with {
"plugins": ["tailwindcss", "autoprefixer"]
} |
We could do a import autoprefixer from "https://esm.sh/autoprefixer";
import tailwindcss from "https://"
export default {
plugins: [tailwindcss, autoprefixer]
}; or whatever else is the format for adding plugins to PostCSS (I haven't used it that much). |
@shadowtime2000 |
@ije @shadowtime2000 import taildwindcss from ' https://'
import autoprefixer from ' https://'
export default {
plugins: [...otherPlugins, postcss([tailwindcss({}), autoprefixer({})]
} I'm not sure what do you think ? |
@yiss i want to support postcss out of the box, no extra plugins needed, if you want to configure the postcss plugins you can do like: {
"plugins": [{"name": "tailwindcss", "options": {}}, {"name": "autoprefixer", "options": {}}]
} |
@ije Seems reasonable since most people would want to use PostCSS and might not want any other plugins. I have a question though, is there a way to specify plugins in the project folder? |
import plugin from "./your-postcss-plugin.ts"
// import tailwindcss and autoprefixer automaticlly from NPM
export default {
plugins: [plugin, "tailwindcss", "autoprefixer"]
}; |
Can add this issue to v0.3.0 roadmap? #5 |
I think there are already enough things that sill need to be done for v0.3.0, we could try to get it done by then, but I think it would best fit on the roadmap for v0.4.0/future. |
I tried to set up http://twind.dev/ with aleph, but it requires some stuff for it to work in SSR :)
works kind of :) since it's client-only (but causes markup to flicker, official solution to set |
@JLarky this is vary interesting! i will try it, thanks! |
@JLarky how do you use that unnamed import? I tried using twind with aleph but I keep getting an error:
I just modified import type { ComponentType } from 'react'
import React from 'react'
+import { tw } from 'https://cdn.skypack.dev/twind'
export default function App({ Page, pageProps }: { Page: ComponentType<any>, pageProps: any }) {
return (
- <main>
+ <main className={tw`h-screen bg-purple-400 flex items-center justify-center`}>
<head>
<title>Hello World - Aleph.js</title>
</head>
<Page {...pageProps} />
</main>
)
} And if I pass
The content of
@ije I think there's some bug in how module URLs are mapped to resources in |
I don't have the project at the moment, but you should check this discussion tw-in-js/twind#70 (comment) |
I'm new to Deno/Aleph, come from a node/react background. Is there clear/easy way to add tailwind to a new Aleph project? |
i have a radical idea...i want to add a feature for the compiler (not very difficult) to collect the classnames at the compilation pahse, then create the minimum css by usage! no tailwindcss compiler needed or import a huge css! |
@ije I think a TailwindCSS implementation called WindiCSS did that and then Tailwind CSS is creating a JIT compiler which does that. But we could look at generalizing that for just CSS. Like if we have this in the CSS: .asdf{color:red;}
.asdf2{color:blue;} and we had this code: <div className="asdf"> we would just collect that |
I see the aleph.config.ts with postcss and options for adding plugins, will configuration options be allowed so I can just plug in tailwind into the postcss processor? |
@aadamsx Correct, you can now configure PostCSS. TailwindCSS doesn't properly convert and we would have to wait until they add Deno support, postui/esm.sh#10 |
I've gone on an adventure to hunt down this. I was getting this error too when importing The code where the error is found is: init((injected = styles.forEach(inject2), true)=>injected Which indeed has a syntax error; it should be: init((injected = (styles.forEach(inject2), true))=>injected And if you make the change on the cache directory it actually does work. The original file where that line comes from at twind has the parenthesis. And if we go to the source of the file at It might have to do with this issue reported on SWC swc-project/swc#1566 And that's as far as I could go. In theory SWC in Aleph was updated to the latest version 5 days ago ( 5d1915e ) and that PR should already be in use by Aleph, but my Rust is limited and I couldn't figure it out further. There is another PR that modified that fixer.rs file and removed some of the code added on that PR, maybe the fix was reverted? swc-project/swc#1561 |
@Zequez thanks, that is helpful! i will try to upgrade swc again to check out whether it's fixed, or i will make pr to swc project |
is it possible to use tailwind yet? |
now we can write plugin for alephjs to support tailwind: https://alephjs.org/docs/api-reference/plugin-api#tailwind-jit-for-jsx |
Thanks @ije, but can we get a project repo example of tailwind working with Aleph -- complete with configurations? |
@aadamsx will add it later, also need to check out how to compile css for tailwind in deno, currently the compiler records all the static class names in jsx files |
@ije great! if you get this all working and complied and provide a tailwind deno demo with configuration, I'll take a look at using Aleph once again! |
Just added a tailwindcss example in https://github.com/alephjs/aleph.js/tree/master/examples/tailwindcss, that is using the windicss plugin |
With recently published TailwindCSS Standalone CLI it's quite easy to use TailwindCSS with PostCSS needs to run first for imports to be inlined, resulting css can then be piped to TailwindCSS CLI. const twprocess = Deno.run({
cmd: [
"cmd", "/C", "./tailwindcss-windows-x64", "-i", "app.pcss", "-o", "app.css", "-c", "tailwind.config.cjs",
]
});
await twprocess.status();
twprocess.close(); TailwindCSS Cli includes cssnano (use with |
@ije That link is broken when I try to follow it. |
I discovered AlephJs and I really love it, it just works out of box like magic. I'm trying to add support for TailwindCSS but I have no I idea where to start.
The documentation here suggest to use PostCSS but I don't think there is a PostCSS plugin in Deno yet : https://tailwindcss.com/docs/installation
Edit :
I checked this pull request #41 and I think we can do something similar for PostCSS
The text was updated successfully, but these errors were encountered: