Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why do I have to rebuild tailwind every time I make a change to my templates?

I'm trying to use tailwind postcss set up but tailwind is not recognizing new classes within my html files. I have to rerun the build process every time I add a class to my html templates. I'm getting no errors when I run my build process.

tailwind config

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['../../templates/auctions/*.html', '../../templates/**/*.html'],
theme: {
    extend: {},
},
variants: {},
plugins: [],
}

package.json

 {
  "name": "jstools",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "build": "tailwind build -i ../auctions/tailwind.css -o ../auctions/output.css && cleancss -o ../auctions/output.min.css ../auctions/output.css"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "clean-css-cli": "^5.6.1"
  },
  "description": "",
  "devDependencies": {
    "autoprefixer": "^10.4.12",
    "postcss": "^8.4.18",
    "postcss-cli": "^10.0.0",
    "tailwind-watch": "^0.0.6",
    "tailwindcss": "^3.2.1"
  }
}
like image 440
Dunham Avatar asked Oct 20 '25 10:10

Dunham


1 Answers

There may be many causes, such as caching issues or changes in the configuration. When a rebuilt is necessary every time a new class is added to the HTML, you can add --watch in the build command in your package.json file:

{
    "scripts": {
        "tailwind-watch": "tailwindcss build -i resources/css/site.css -o public/css/style.css --watch"
    },
}
like image 127
iep Avatar answered Oct 22 '25 00:10

iep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!