-
Notifications
You must be signed in to change notification settings - Fork 280
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
Setting up Tailwind ... documentation / maybe bugs #842
Comments
Hi Dan, thanks for bringing this up! It's indeed confusing so let me clarify a couple of things: Hydrogen is now built on top of Remix, and it's actually the latter the one in charge of assets like CSS. If you want to use Tailwind right now, I'd recommend doing what you see in the demo-store template (the link above shows how). It will be easier to migrate to the latest version of Remix once Hydrogen supports it.
I think this should be supported when using the new feature (
This is probably by design in Remix. They mention to process your files beforehand. However, since now they support PostCSS, perhaps you could give postcss-sass a spin and see if that works.
You can try some of the workarounds listed in this Tailwind repo discussion.
I'm not 100% sure since it seems this behavior has been modified several times. I think it should be automatic but we'll double check this again soon. It can't hurt to add it manually, in any case. -- Edit: I just remembered, the reason we don't add it in the demo-store it's because it's already included in We are going to add more scaffolding features to the Hydrogen CLI soon, and one of them will be adding Tailwind to a new project. We will also update our guides once this is ready. |
Hi @frandiox Thank you - I appreciate you taking the time to provide clarity and for considering my report which might not fall into the traditional bug/fix scenario. Yes, we are very reliant on the documentation as there are a lot of considerations (as well as unfamiliar / cutting edge tech) to get one's head around, but having the demo-store as the most reliable source of reference is very helpful to know. From your replyI have updated my configuration based on the github change summary - so useful - ta. Remix 1.16 looks like quite a few major changes - I think I had better wait until the demo store is updated otherwise I'm going to break things - it's a natural talent :-) For SCSS - I'll take a look at postcss-sass, cheers. Having CLI updates for new projects will be good, I don't use the CLI as I prefer to understand any changes being made. The Shopify admin offers a process of getting started that which uses the barebones / demo-store. That's the process I'm personally following i.e. copy, explore, understand, modify. But I'll take a look at the CLI and make sure I'm not missing productivity tricks / features. Thanks for the autoprefixer info. Nice to know it's there somewhere! FeedbackTailwind future flags - this allowed @apply to work. Yay! However, unless I've missed something, I cannot get layers to work e.g. @layer base {}, @layer components {}, @layer utilities. Plus, I can only reference other files, not from tailwind.css, but it has to be from within app.css. I presume the @layer directive will work in Remix 1.16? Happily ignoring lint errors which are no longer breaking, although still underlined. Questions
Now that apply is working and I can split up my files and that's a big obstacle removed (thank you!). Then, yes, I can go back and update my code with Remix 1.16 so it's more Tailwind friendly. Anything I've said that's wrong - do feel free to correct me or provide extra info / pointers. Much appreciated. Many thanks for your help. Update: I may have spoke too soon - I'm slowly importing the demo-store files (and removing the old code that was based on the Shopify Hydrogen tutorial documentation) so I can learn. But I did receive the following error which means my fears were realised...
If you have any suggestions - I'm all ears - will post an update when I've finished importing and testing. It may be a case of waiting for 1.16 though. |
Just a quick update: I am updating my local project to the latest demo-store-ts template. Will feedback on the Tailwind issues soon. However in the meantime I wanted to report some unexpected behavior when updating to the latest template (that was updated just a few days ago). I spent the evening copying and pasting over the code (I know, I know but it's just a way for me to familiarise myself with the code). Added just the index page. It worked for a moment and then routing errors started (errors every half a second from one page). This was a valid routing error because I had not included the countries API route. So I added it. Added the rest of the routes and but then continued to get the error complaining about the the route and countries api and referencing the route $ as an issue as though it was interpretting countries api as a catchall from the $ (or $_) route. Sorry I cleared my terminal otherwise I would have shared. Explored and compared code for a few hours to find out what might be causing it (presuming human error). Couldn't see anything that didn't match the live demo store. I had removed all old code files before I started the copying process. So, since the error, I changed no code. Confirmed all configuration settings were correct including Package.json, ran package install twice. Restarted Ctrl + C the dev server multiple times. No matter what I did I just kept getting a route error. Next day and PC reboot - it suddenly started to work as expected. It's like restarting the local dev server via Ctrl + C then npm run dev didn't seem to properly restart the service. I believe there may be a problem e.g.
Is there a command to fully restart the local dev server or prevent any caching from previous runs of npm run dev? Deleting countries api route, running the server, putting it back, restarting server is the only way I might try to reproduce this error (but not tried it yet) - just thankful it's working as limited knowledge of remix. There may be no big issue to solve, but if you are at least aware of it, it may be that others have this issue too and then it becomes worth looking into. Will keep you posted on the original Tailwind issue in a few days. Thanks, |
Just a quick update - sorry been busy running business - still delving into this. Update 1 - I found that some tailwind styles were not re-ordering - after adding prettier-plugin-tailwindcss (dev tool) it worked fine. Update 2 - CSS caused errors when importing from demo-store - it looks like the demo-store app.css is using scss / sass in app.css?? Or am I missing a config that would make this error free css? .prose { Update 3 - Opened up a stack overflow question regarding @importing tailwind custom styles Will keep you posted. Thanks, |
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2023.4.0
What version of Remix are you using?
1.15.0
Steps to Reproduce
Hello,
I appreciate the time to look at this. I'm trying to set up a simple project. I started with the most basic template via the Hydrogen GitHub project creation (barebones sample, not the full demo store).
I'm finding a few things that are either outright confusing (which is a shame because you have built something amazing and I'm really excited!), or things that don't work like I would expect in a traditional Tailwind/React project.
Maybe it's by design. Maybe there are bugs. I'm sorry if I'm wrong - I'm new to Hydrogen. Maybe these problems will be similar for others, so hopefully looking at the below you make it easier for others on a similar journey.
Bug 1 (docs)
Preamble of confusion...
On https://shopify.dev/docs/custom-storefronts/hydrogen/building/begin-development
The package json scripts section is...
On https://github.com/Shopify/hydrogen/blob/dist/templates/demo-store-ts/package.json
The package json script section is just...
Documentation confusion - why are there two very different ways of setting up a package.json?
The second one is in a project that uses Tailwind.
Bug 2 (coding)
@apply only works if placed into Tailwind.css
Does not work in css files that have been included via @import
Bug 3 (coding)
Tailwind typically works with scss out of the box - there seems to be "no loader" for SCSS. By design or bug?
Bug 4 (coding)
Unknown at rule @apply (just a lint error but not remedied by installing the Tailwind CSS Intellisense for VSCode.
Same with @tailwind
Bug 5 (coding / documentation)
postcss.config.js in Minimal code template
Yet on https://github.com/Shopify/hydrogen/blob/dist/templates/demo-store-ts
It's the below but with no mention of autoprefixer. Is it a bug that autoprefixer has been omitted here?
Or is autoprefixer automatic?
Expected Behavior
Bug 1 - if both these samples are inclusive of Tailwind the documentation should demonstrate one clean way of doing things? I don't see the advantage of one over the other. If there is a worthy / valid difference, can the documentation be updated with a note?
Bug 2 onwards
I would expect a single entry point Tailwind.css file with
--
In those files imported, I would expect the @apply function of Tailwind to just work.
Have compared configuration to a simple React/Tailwind application and cannot find any reason Hydrogen app shouldn't work the same way based on configs I can see in the Hydrogen project. Is there a configuration setting needed?
Similar problem with the postcss.config.js - seemingly two different ways to do something. Yet the one mentions autoprefixer, the other does not. Missing AutoPrefixer bug or now built in behind the scenes?
Actual Behavior
First time submitting a "bug" - please be kind :-)
Thank you again!
Dan.
The text was updated successfully, but these errors were encountered: