So currently, from what I found, there are only about 3 or 4 articles that show you how to add TailwindCSS to a Svelte app. And I'm pretty sure the...
For further actions, you may consider blocking this person and/or reporting abuse
Running
npm run dev
starts two servers for me. The second stating that port 5000 is already used and it uses a random one.I think the first is coming from the script
start:dev
and the second fromautobuild
. I guessstart:dev
is not required at all, becauseautobuild
respectivelyrollup -c -w
is already runningsirv
.I think you're right. I changed the dev script to "run-p autobuild watch:tailwind" which works just fine
Alright, then I leave it like that and by the way thank you for the post!
The
run-p
keyword used in the scripts in the package.json will lead port 5000 of localhost could not be used and jump to another random port. I change it to run-s, now it is OK. What is the reason of this?I had the same problem and changed my dev script to: "dev": "run-p autobuild watch:tailwind" - which seems to work fine for me
Thanks for that post!
2 questions:
tailwind.css
into the public folder ? It seems to me that only the generatedindex.css
needs to be there and it makes more sense to puttailwind.css
undersrc/
!?@apply
rules in thestyle
section seem to get lost or not effective (Before i had it working with the setup of dev.to/sarioglu/using-svelte-with-...). Any way to make this work as well ?2) This tutorial seems to follow a minimalist mindset and only compiles postcss files, not svelte files. If you want to process postcss in svelte files, follow the other tutorial for everything but purgecss. Everything else that differs is because he is calling postcss directly instead of using
svelte-preprocessor
which you need for running postcss in svelte files.1) Source file doesn't have to be there, may need to be moved depending on your tooling. If you follow the other tutorial, both files and the generating npm commands should be deleted and contents put in the
<style global>
instead.Thanks for this tutorial. I found it really helpful
I'm currently experimenting with Tailwind and still getting my head around the ugly but useful convention of placing lots of modifiers in the markup directly. Quick question: if Svelte automatically scopes our CSS for each component, what would be the advantage of using Tailwind at all? Wouldn't it be cleaner to have the styles inside Svelte's tag instead?</p>
Exactly what I was looking for. Thanks for the post!
Great post.
I get the following error on npm run build
'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.
Ok. This solves it.
npm install --save-optional win-node-env
this is brilliant, worked for me!
Excellent tutorial. Should replace the one written by Tailwind author :)
Do you have a clue how to get this to work with sapper?
For my sapper project I was able to get it running by following steps 1-3 as above then branching off as below:
Step 4: Create
static/tailwind.css
and add importsStep 5: Add
<link rel='stylesheet' href='index.css' />
tosrc/template.html
Step 6: Adjust run scripts as follows:
Then can simply start up with
npm run dev
I've created a template for sapper based on this: github.com/jadbox/sapper-tailwind-...
npx degit "jadbox/sapper-template#rollup-tailwind" sapper-tailwind
Hi Jonathan, I see this in my editor when looking at index.svelte
Error in svelte.config.js
Error: ENOENT: no such file or directory, uv_cwdsvelte
any ideas, the app seems to run ok.
There's an error when using @apply
If I run "watch:tailwind" the index.css is generated, but not with "dev"! Any hints on this?
Thanks very much, this helped me finally get Svelte and Tailwind working nicely together.
Thx for this, helpful!
I tried it but I am getting 66k lines in index.css output, so purge can't be working here?
Thanks for sharing!
Anyone knows why I'm getting this error?