-
Notifications
You must be signed in to change notification settings - Fork 185
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
feat(lit-dev-content): add lit-with-tailwind guide #1278
base: main
Are you sure you want to change the base?
Conversation
/gcbrun preview URL: https://pr1278-81e742c---lit-dev-5ftespv5na-uc.a.run.app/articles/lit-with-tailwind/ |
Hi! @43081j, @augustjk. Nice to meet you! Today I just reviewed t39/import-attributes support and I noticed that the spec was updated and the previous 'with' keyword came back. So... I think maybe we need to wait for a little (with stability in mind) and see how the ecosystem moves. PS: I was surfing and I find this PR 🤣, sorry for any inconvenience |
I have mentioned that in the article esbuild doesn't seem to support the latest standard out of the box, so the article still uses I don't think we need to wait. It is pretty much settled now on import attributes ( |
Agreed. I think it's fine to publish now with the notes and update when we can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! A few suggestions for typo and questions for my understanding of the solution.
It would also be nice to have a thumbnail to show up on https://pr1278-81e742c---lit-dev-5ftespv5na-uc.a.run.app/learn/
Normally I'd ask Andrew for his artistic talents but he's off on vacation til next year. Maybe it won't be hard to throw together something with the Lit and Tailwind logos. Time to bring out my MSPaint skills?
packages/lit-dev-content/site/articles/article/lit-with-tailwind.md
Outdated
Show resolved
Hide resolved
packages/lit-dev-content/site/articles/article/lit-with-tailwind.md
Outdated
Show resolved
Hide resolved
packages/lit-dev-content/site/articles/article/lit-with-tailwind.md
Outdated
Show resolved
Hide resolved
packages/lit-dev-content/site/articles/article/lit-with-tailwind.md
Outdated
Show resolved
Hide resolved
- Use [import attributes](https://github.com/tc39/proposal-import-attributes) | ||
to import those CSS files | ||
- Use [esbuild](https://github.com/evanw/esbuild) to pull those CSS files | ||
into the bundle or same output directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm not too familiar with features in this area and this is more for my understanding of what's going on.
Looking at the output from the example repo, esbuild produces this line in the bundle
import styles from "./hello-world-4K4DCJGM.css" assert { type: "css" };
esbuild is being used to bundle and move the css files into the outdir and is it then left up to the users to make this work on unsupported browsers? We probably need a loud caveat stating this only works in Chrome if that's the case. Can es-module-shims
be used to make it work for other browser?
Might there be rollup plugins that work with the new correct import attribute syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... latest esbuild actually does support import attributes with the with
keyword. https://github.com/evanw/esbuild/releases/tag/v0.19.7
evanw/esbuild#3384 (comment) Evan does say type: 'css'
support will come to esbuild eventually but perhaps a plugin can be written for it in the mean time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah pretty much, right now it just outputs the source as-is (i.e. your browser needs to support import assertions at least, ideally attributes too).
the esbuild blockage is because of no support for CSS. you're right though, we may be able to use a plugin, i'll have a dig around
it'd be nice to not have to use rollup, just because it consumes most of the build whereas esbuild focuses on only the bundling (as in we should also do the tailwind preprocessing in rollup, if we use rollup).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense. i don't disagree with the tool choice and i don't want to block or dictate too much as to what this article should say.
since this article being the first of its kind, i think it would be good to convey to the reader that this is meant as one way to solve this problem, with caveats like browser support, and mention alternatives (even without details) like using rollup plugins for all the steps. being published on lit.dev, people might consider this the only recommended way otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heya, seeing how with
is shipped in chrome now + TS 5.4 supporting it, can we switch to with
?
Thanks for the article @43081j !! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I LOVE the image you have but there might be a potential legal issue:
Their brand guidance states:
You may not use the Tailwind name or logos in any way that could mistakenly imply any official connection with or endorsement of Tailwind Labs Inc.
I think inclusion of the logo like this can be construed as an endorsement. Maybe you can use the literal unicode ≈
as an alternative and standard arial or Manrope text. Or just Lit + Tailwind with Manrope font or standard arial
- Use [import attributes](https://github.com/tc39/proposal-import-attributes) | ||
to import those CSS files | ||
- Use [esbuild](https://github.com/evanw/esbuild) to pull those CSS files | ||
into the bundle or same output directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heya, seeing how with
is shipped in chrome now + TS 5.4 supporting it, can we switch to with
?
|
||
An example repository very similar to this guide is available here: | ||
|
||
https://github.com/43081j/tailwind-lit-example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do a link that's like:
[Source](https://github.com/43081j/tailwind-lit-example)
[Live demo](https://githubblitz.com/43081j/tailwind-lit-example)
All you would also need to do is have a start
npm command that starts a server so that we can serve it like with WDS.
Here is an example with wds and a dev command:
https://stackblitz.com/edit/github-8tsp9c?file=src%2Fhello-world.ts
I'll try get the branch caught up and see if everything now works fine with import attributes A designer friend of mine made the image. I'll ask her nicely and see if she can update 😅 I think it would make sense to just use text for the tailwind part and drop the logo |
This adds a guide for using tailwind (and similar libraries) with lit components. For now, using the older import assertions proposal since esbuild doesn't yet support import attributes out of the box it seems.
we're in a bit of a pickle with a stackblitz example 😬 it seems we can't use i don't really want to get everyone to duplicate an esbuild plugin for something that should really work out of the box but i can't put it back to |
This adds a guide for using tailwind (and similar libraries) with lit components.
For now, using the older import assertions proposal since esbuild doesn't yet support import attributes out of the box it seems.
for the author meta, i just dumped my twitter avatar in with the other images and updated the json. hopefully that works, i don't have many photos lying around 😂