Tailwind Setup via CLI
Overview
Practice installing Tailwind CSS for NEW projects
Create build process for apps using Tailwind CSS
Install Tailwind CSS using the CLI tool
Setup repo with Node and npm package manager
Create a new repo with

Open newly created repo in CodeSpaces
From the Terminal
Setup
npm
project with common defaults
npm init -y
A new file named
package.json
will automatically be created
npm
is the package manager, but does not run/execute ita new file named
package-lock.json
will automatically be createda new folder named
node_modules
will automatically be created
npm install -D tailwindcss
Tailwind is downloaded but installed, but is not running or configured
a new file named
tailwind.config.js
will automatically be created
npx tailwindcss init
Create these folders and files
src/input.css
public/index.html
public/style.css
public/script.js
Open
tailwind.config.js
find
content :
keymodify value to
["./public/*.{html,js}"],
What is happening now? We're configure the paths the HTML template or JS components. Or "Tailwind put all the compiled code in this folder" named public
Add the @tailwind
directives
open
src/input.css
add this code
@tailwind base;
@tailwind components;
@tailwind utilities;
For right now, copy all this code.
{
"name": "Tailwind CSS Starter Kit",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "Hello 😃!",
"dev" : "tailwindcss -i ./src/input.css -o ./public/style.css --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"tailwindcss": "^3.3.3"
}
}
7. Start the Tailwind CLI build process
The shortcut we created is
npm run dev
use
npm
to get the sourceinput.css
compile tostyle.css
--watch
for any changes oninput.css
, then re-compile tostyle.css
Setup boilder plate for HTML in
public/index.html
Write all CSS in
src/style.css
Write all JS in
public/script.js
Run Live Server on
index.html
Click on
public
folder to view in browser
Note: index.html
is public/index.html
Last updated