-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Dev server must be restarted to have classes applied with Snowpack #3950
Comments
Hey thanks! In this case a reproduction repository would definitely be helpful so we don't have to try and set everything up from scratch 🙏 I've never used Snowpack before so without a reproduction repository it's going to be a lot of work for me to try and recreate this problem by hand. |
Of course, there it is: repo Sorry for not putting it in the previous message. By the way, thanks a lot for the quick answer 🚀 :) |
Hello. If I may chip in I can't get the JIT watcher fully working with Snowpack either. Very simple repo https://github.com/Xeevis/tailwindcss-jit-snowpack pnpm install
pnpm watch When I change the |
Can confirm same behavior with |
You can explicitly configure TAILWIND_MODE to be Set the env variable as
This environment variable seems to solve the problem. |
Interesting. This does indeed resolves the problem (with rollup at least), but I wonder if it's correct behavior, considering that it still automatically generates new styles when changing CSS files without the variable |
Yeah that's correct behavior, the template watching is handled by us but the CSS file watching is handled by the build tool which explains why you're seeing that. We'll figure out how to make this more intuitive/automatic over time for sure. |
Hi, "scripts": {
"start": "snowpack dev",
"build": "snowpack build",
"watch": "TAILWIND_MODE='watch' yarn start"
} Can't figure out why I still have this issue :/ |
@samueldrai just cloned your repo but it looks like Tailwind isn't even listed as a dependency, nor is there a tailwind.config.js file or anything like that so I'm not sure where to start here. I feel like a moron saying "you need to install Tailwind for Tailwind to work" but that's about the only advice I can offer currently, haha... Can you update the repo with your latest efforts? |
No dice here with snowpack, since I'm on Windows tried to change env with cross-env
Doesn't work in either dev or watch. Saving My code https://github.com/Xeevis/tailwindcss-jit-snowpack |
@adamwathan sorry for the back and forth. The problem was that the repo was a repo from my company and I could not share it directly. 😅 |
@samueldrai I also trying the same thing in my PHP project using
// snowpack.config.js
// ...
plugins: [
[
'@snowpack/plugin-run-script',
{
cmd: 'postcss ./app/assets/css/style.css -o ./public/css/style.css --no-source-map', // production build command
watch: 'postcss --watch ./app/assets/css/style.css -o ./public/css/style.css --no-source-map', // (optional) dev server command
},
],
],
// ... then just |
@bramaudi this workaround does work somewhat better, thanks! Edit: It takes the build out of the Snowpack pipeline which is problematic if you want to use new Integrated build optimizations or @snowpack/plugin-optimize However when I remove classes from template file, it won't get purged from the css, it only appends new classes. For purge I need to bump save CSS file. This doesn't feel right, is this expected behavior with the JIT @adamwathan ? Tb9u1zo87V.mp4 |
@Xeevis Yeah that's been discussed before, it's a deliberate performance optimization that assumes people are always doing a fresh build when actually building for production: tailwindlabs/tailwindcss-jit#57 It is surprising to me to learn that people run a watcher in development and are actually committing the output of the watcher, I thought everyone was building assets like this at deploy 😲 |
Hey @adamwathan, I set another repo up with the changes so you can try it out: https://github.com/thomasruiz/snowflake-tailwind If I try to change App.tsx and change the bg-blue class, the browser refreshes, but the classes are not generated. |
Tailwind noob here, but I'm also excited about this jit effort and having trouble with the development workflow for I tried using the script solution proposed by @bramaudi to trigger postcss to watch my js and html files, but it hangs immediately on any the non-css syntax e.g., a js file (should have mentioned I'm also a postcss noob too). Of course, I also tried it as intended, watching my projects css file. I also tried leveraging the I'm hoping there is a way to get the jit to fire again when I edit my templates or markup files, or maybe there's some other argument or incantation I missed that can get it working as well as it clearly does in webpack. |
EDIT: Published as npm package, read instructions here https://github.com/JadeX/snowpack-plugin-tailwindcss-jitThis may be a compatibility problem with the |
@Xeevis the local plugin idea works a charm. Don't forget to |
@austinorr I've managed to use tailwind's purge globs. JIT works pretty well for me now with Snowpack, only thing left to do is to get rid of the hardcoded CSS file. I guess only way to do that is to read and determine which CSS files hold the Tailwind imports. Anyway here is video using purely yJh1AWs9OV.mp4 |
I've published new Snowpack plugin that should help with this issue without any extra configuration. Can you guys test it if it works for you too? https://github.com/jadex/snowpack-plugin-tailwindcss-jit |
Here's the reproduction repo🎉 Repo Edit some classes to see the effect. |
Why tailwindlabs/tailwindcss-jit#181 is closed? |
Possible reasons might be: Snowpack caches everything indefinitely. That's why it gives ⚡ fast performance from the beginning. And in my opinion the whole point of JIT is already built into Snowpack. |
The problem with Snowpack is it doesn't have support for PostCSS's dependency message API. We are working on a PR to Snowpack to fix this.
Because it's a duplicate of this issue and we only want one issue per problem. |
Really happy that you guys are working on it😄😄 |
what about that PR that you are working on?? |
Dude if you ever send me a message with two question marks in a row in it again I am gonna ban you from our repositories :/ We are working hard, we have 500 things to work on, this is one of them. Relax. |
Issue similar to https://github.com/tailwindlabs/tailwindcss-jit/issues/202 |
This works for me, good work, thanks! |
I have this issue with rollup. |
This is happening to me as well on a Next JS project running inside Docker. The only way for my changes to be updated is by opening up |
@mustafa0x @mrodrigues95 can you both try setting TAILWIND_DISABLE_TOUCH=true? It will use an alternative watch method that is actually a bit better but doesn't work with all build tools (works with webpack and Rollup though). |
Thanks, that did it! |
@adamwathan In my case, setting |
@adamwathan I believe this issue can be closed, Snowpack has added official support for TailwindCSS JIT in version Install instructions available in the docs https://www.snowpack.dev/guides/tailwind-css On the side note combined with TailwindCSS |
@Xeevis what's your configuration? For me it works only after manual page refresh and only when developer tools are open (Chrome).
This is snowpack.config.js:
This in tailwind.config.js:
And this in postcss.config.js:
|
@teenjuna I have added "scripts": {
"dev": "TAILWIND_MODE=watch NODE_ENV=development TAILWIND_DISABLE_TOUCH=true snowpack dev",
}, I also had to upgrade to TailwindCSS 2.2.0 canary for it work for other markup files for purge other than npm install -D tailwindcss@canary |
@Xeevis Interesting... This combination creates some kind of infinite self-triggering loop on my machine |
Hey all.
Here is a bare-bones example project: https://github.com/bradlc/jit-snowpack If you are still having problems after following these instructions please open a new issue with a reproduction, thanks! |
Repro of @teenjuna's issue: https://github.com/adamburgess/jit-snowpack Fix is to either
The best solution here is probably 3, as there might be some valid reasons why css files should be able to depend on other css files (not in a cycle, though) |
Hey! Please open a new issue like @bradlc mentioned in his last comment, it's the only way we won't lose track of it as we can't easily monitor closed issues. |
Oh, ok |
What version of @tailwindcss/jit are you using?
0.1.4
What version of Node.js are you using?
14.2.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction repository
https://www.youtube.com/watch?v=G6d-SXdcJXs
Hi there☺️
I tried to use this new JIT feature with a new React app built with Snowpack.
Unfortunately, I cannot have Snowpack use Tailwind JIT properly.
I think I might have missed something about the configuration process.
When changing a class in a component, I have to stop and restart the dev server.
Here are my config files:
Thanks!
The text was updated successfully, but these errors were encountered: