Skip to content

Instantly share code, notes, and snippets.

@nurmdrafi
Last active August 3, 2022 15:56
Show Gist options
  • Save nurmdrafi/d5301cee79c8a1c66b54d2740aea8b70 to your computer and use it in GitHub Desktop.
Save nurmdrafi/d5301cee79c8a1c66b54d2740aea8b70 to your computer and use it in GitHub Desktop.
  1. node.js required
  2. npm init -y (initialize node project)
  3. install Tailwind CSS Intellisense VS Code Plugin
  4. npx tailwindcss init (create configure files for tailwind)
  5. create src/input.css or any name
@tailwind base;
@tailwind components;
@tailwind utilities;
  1. create .vscode/settings.json file [Optional]
{
"css.validate": false,
"tailwindCSS.emmetCompletions": true
}
  1. add the paths inside tailwind.config.js
/** @type {import('tailwindcss').Config} */ 
module.exports = {
  content: ["./src/**/*.{html,js}"], // where actually tailwindcss looking for used class and purge
  theme: {
    extend: {},
  },
  plugins: [],
}
  1. insert build script
"scripts": 
{
"build": "tailwindcss -i ./src/input.css -o ./output.css --watch"
}
// input path | outputh path | watch flag => auto rebuild after changes
  1. create src/index.html and link /dist/output.css
<link href="/dist/output.css" rel="stylesheet">
  1. npm run build (this command do not required for react app)
  2. Automatic Class Sorting with Prettier
  • install
    • npm install -D prettier prettier-plugin-tailwindcss
  • enable format on save
  • npx prettier --check . // check all files
  • npx prettier --write . // formate all files

Note

  • before v3 CDN cannot customizable
  • install as PostCSS Plugin is not recommanded for beginner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment