In this article I will show you how to install TailwindCSS for use in a basic ExpressJS app. This nodejs project had no other dependencies as I just wanted to install tailwindcss.
After initializing the expressjs project, I added a folder that would host my stylesheet :
After that, I created two stylesheet files. One will hold the source code for my styles, and the other one is the output that will be generated by tailwindcss.
Now, install the tailwindcss :
Open your recently created
source.css located in
./public/stylesheets/source.css and add the tailwindcss injections :
Then you want to generate your
style.css file so you can actually use in your project. Simply use npx and generate the file.
Voila! You have installed tailwindcss. Now simply go into the file that hosts your layout for the project and add the stylesheet in your header
I also added this command to my
package.json and made it look like so :
Optionally, if you would like to add extra configurations to your tailwindcss setup, you can initialize a settings file via npx:
This will create
There you go, tailwindcss in your basic expressjs project in 5 minutes.