Tailwind not running in my Rails App. How can I see the issue so I can debug it

I switch my app from webpacker to esbuild. My biggest issue is I don’t know how to debug the problem.
When I run bin/dev it exits when it running js: yarn build –watchcss: bin/rails tailwindcss:watch

I tried thing like –trace and no additional information. I ran yarn build –watchcss: bin/rails tailwindcss:watch by its self and nothing happened. No errors or flags

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>16:43:45 web.1 | started with pid 99535
16:43:45 css.1 | started with pid 99536
16:43:45 js.1 | started with pid 99537
16:43:45 css.1 | yarn run v1.22.19
16:43:45 js.1 | yarn run v1.22.19
16:43:45 css.1 | $ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch
16:43:45 js.1 | $ node esbuild.config.mjs --watchcss: bin/rails tailwindcss:watch
16:43:46 js.1 | Done in 0.41s.
16:43:46 css.1 |
16:43:46 css.1 | Rebuilding...
16:43:46 js.1 | exited with code 0
16:43:46 system | sending SIGTERM to all processes
16:43:46 web.1 | terminated by SIGTERM
16:43:46 css.1 | exited with code 1
</code>
<code>16:43:45 web.1 | started with pid 99535 16:43:45 css.1 | started with pid 99536 16:43:45 js.1 | started with pid 99537 16:43:45 css.1 | yarn run v1.22.19 16:43:45 js.1 | yarn run v1.22.19 16:43:45 css.1 | $ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch 16:43:45 js.1 | $ node esbuild.config.mjs --watchcss: bin/rails tailwindcss:watch 16:43:46 js.1 | Done in 0.41s. 16:43:46 css.1 | 16:43:46 css.1 | Rebuilding... 16:43:46 js.1 | exited with code 0 16:43:46 system | sending SIGTERM to all processes 16:43:46 web.1 | terminated by SIGTERM 16:43:46 css.1 | exited with code 1 </code>
16:43:45 web.1  | started with pid 99535
16:43:45 css.1  | started with pid 99536
16:43:45 js.1   | started with pid 99537
16:43:45 css.1  | yarn run v1.22.19
16:43:45 js.1   | yarn run v1.22.19
16:43:45 css.1  | $ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch
16:43:45 js.1   | $ node esbuild.config.mjs --watchcss: bin/rails tailwindcss:watch
16:43:46 js.1   | Done in 0.41s.
16:43:46 css.1  | 
16:43:46 css.1  | Rebuilding...
16:43:46 js.1   | exited with code 0
16:43:46 system | sending SIGTERM to all processes
16:43:46 web.1  | terminated by SIGTERM
16:43:46 css.1  | exited with code 1

My tailwind.config.js looks like

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const colors = require('tailwindcss/colors')
const defaultTheme = require('tailwindcss/defaultTheme')
/** @type {import('tailwindcss').Config */
module.exports = {
darkMode: 'class',
plugins: [
require('@tailwindcss/aspect-ratio'),
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
],
content: [
'./app/components/**/*.rb',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.erb',
'./app/views/**/*.haml',
'./app/views/**/*.slim',
'./lib/jumpstart/app/views/**/*.erb',
'./lib/jumpstart/app/helpers/**/*.rb',
],
theme: {
extend: {
colors: {
purple: colors.purple,
primary: colors.blue,
secondary: colors.gray,
tertiary: colors.gray,
danger: colors.red,
success: colors.green,
info: colors.blue,
warning: colors.yellow,
},
fontFamily: {
sans: ['Inter', ...defaultTheme.fontFamily.sans],
},
},
},
future: {
},
}
</code>
<code>const colors = require('tailwindcss/colors') const defaultTheme = require('tailwindcss/defaultTheme') /** @type {import('tailwindcss').Config */ module.exports = { darkMode: 'class', plugins: [ require('@tailwindcss/aspect-ratio'), require('@tailwindcss/forms'), require('@tailwindcss/typography'), ], content: [ './app/components/**/*.rb', './app/helpers/**/*.rb', './app/javascript/**/*.js', './app/views/**/*.erb', './app/views/**/*.haml', './app/views/**/*.slim', './lib/jumpstart/app/views/**/*.erb', './lib/jumpstart/app/helpers/**/*.rb', ], theme: { extend: { colors: { purple: colors.purple, primary: colors.blue, secondary: colors.gray, tertiary: colors.gray, danger: colors.red, success: colors.green, info: colors.blue, warning: colors.yellow, }, fontFamily: { sans: ['Inter', ...defaultTheme.fontFamily.sans], }, }, }, future: { }, } </code>
const colors = require('tailwindcss/colors')
const defaultTheme = require('tailwindcss/defaultTheme')

/** @type {import('tailwindcss').Config */
module.exports = {
  darkMode: 'class',

  plugins: [
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/forms'),
    require('@tailwindcss/typography'),
  ],

  content: [
    './app/components/**/*.rb',
    './app/helpers/**/*.rb',
    './app/javascript/**/*.js',
    './app/views/**/*.erb',
    './app/views/**/*.haml',
    './app/views/**/*.slim',
    './lib/jumpstart/app/views/**/*.erb',
    './lib/jumpstart/app/helpers/**/*.rb',
  ],

  theme: {
    extend: {
      colors: {
        purple: colors.purple,
        primary: colors.blue,
        secondary: colors.gray,
        tertiary: colors.gray,
        danger: colors.red,
        success: colors.green,
        info: colors.blue,
        warning: colors.yellow,
      },
      fontFamily: {
        sans: ['Inter', ...defaultTheme.fontFamily.sans],
      },
    },
  },

  future: {
  },
}

My esbuild.config.mjs file is

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import * as esbuild from "esbuild"
import path from "path"
import rails from "esbuild-rails"
import chokidar from "chokidar"
import http from "http"
import { setTimeout } from "timers/promises"
const clients = []
const entryPoints = [
"application.js",
"administrate.js"
]
const watchDirectories = [
"./app/javascript/**/*.js",
"./app/views/**/*.html.erb",
"./app/assets/builds/**/*.css", // Wait for cssbundling changes
"./config/locales/**/*.yml",
]
const config = {
absWorkingDir: path.join(process.cwd(), "app/javascript"),
bundle: true,
entryPoints: entryPoints,
minify: process.env.RAILS_ENV == "production",
outdir: path.join(process.cwd(), "app/assets/builds"),
plugins: [rails()],
sourcemap: process.env.RAILS_ENV != "production"
}
async function buildAndReload() {
// Foreman & Overmind assign a separate PORT for each process
const port = parseInt(process.env.PORT || 3200)
console.log(`Esbuild is listening on port ${port}`)
const context = await esbuild.context({
...config,
banner: {
js: `
(() => {
if (typeof EventSource !== 'undefined') {
new EventSource("http://localhost:${port}").onmessage = () => location.reload()
}
})();
`,
}
})
// Reload uses an HTTP server as an even stream to reload the browser
http
.createServer((req, res) => {
return clients.push(
res.writeHead(200, {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
"Access-Control-Allow-Origin": "*",
Connection: "keep-alive",
})
)
})
.listen(port)
await context.rebuild()
console.log("[reload] initial build succeeded")
let ready = false
chokidar
.watch(watchDirectories)
.on("ready", () => {
console.log("[reload] ready")
ready = true
})
.on("all", async (event, path) => {
if (ready === false) return
if (path.includes("javascript")) {
try {
await setTimeout(20)
await context.rebuild()
console.log("[reload] build succeeded")
} catch (error) {
console.error("[reload] build failed", error)
}
}
clients.forEach((res) => res.write("data: updatenn"))
clients.length = 0
})
}
if (process.argv.includes("--reload")) {
buildAndReload()
} else if (process.argv.includes("--watch")) {
let context = await esbuild.context({...config, logLevel: 'info'})
context.watch()
} else {
esbuild.build(config)
}
</code>
<code>import * as esbuild from "esbuild" import path from "path" import rails from "esbuild-rails" import chokidar from "chokidar" import http from "http" import { setTimeout } from "timers/promises" const clients = [] const entryPoints = [ "application.js", "administrate.js" ] const watchDirectories = [ "./app/javascript/**/*.js", "./app/views/**/*.html.erb", "./app/assets/builds/**/*.css", // Wait for cssbundling changes "./config/locales/**/*.yml", ] const config = { absWorkingDir: path.join(process.cwd(), "app/javascript"), bundle: true, entryPoints: entryPoints, minify: process.env.RAILS_ENV == "production", outdir: path.join(process.cwd(), "app/assets/builds"), plugins: [rails()], sourcemap: process.env.RAILS_ENV != "production" } async function buildAndReload() { // Foreman & Overmind assign a separate PORT for each process const port = parseInt(process.env.PORT || 3200) console.log(`Esbuild is listening on port ${port}`) const context = await esbuild.context({ ...config, banner: { js: ` (() => { if (typeof EventSource !== 'undefined') { new EventSource("http://localhost:${port}").onmessage = () => location.reload() } })(); `, } }) // Reload uses an HTTP server as an even stream to reload the browser http .createServer((req, res) => { return clients.push( res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", "Access-Control-Allow-Origin": "*", Connection: "keep-alive", }) ) }) .listen(port) await context.rebuild() console.log("[reload] initial build succeeded") let ready = false chokidar .watch(watchDirectories) .on("ready", () => { console.log("[reload] ready") ready = true }) .on("all", async (event, path) => { if (ready === false) return if (path.includes("javascript")) { try { await setTimeout(20) await context.rebuild() console.log("[reload] build succeeded") } catch (error) { console.error("[reload] build failed", error) } } clients.forEach((res) => res.write("data: updatenn")) clients.length = 0 }) } if (process.argv.includes("--reload")) { buildAndReload() } else if (process.argv.includes("--watch")) { let context = await esbuild.context({...config, logLevel: 'info'}) context.watch() } else { esbuild.build(config) } </code>
import * as esbuild from "esbuild"
import path from "path"
import rails from "esbuild-rails"
import chokidar from "chokidar"
import http from "http"
import { setTimeout } from "timers/promises"

const clients = []
const entryPoints = [
  "application.js",
  "administrate.js"
]
const watchDirectories = [
  "./app/javascript/**/*.js",
  "./app/views/**/*.html.erb",
  "./app/assets/builds/**/*.css", // Wait for cssbundling changes
  "./config/locales/**/*.yml",
]
const config = {
  absWorkingDir: path.join(process.cwd(), "app/javascript"),
  bundle: true,
  entryPoints: entryPoints,
  minify: process.env.RAILS_ENV == "production",
  outdir: path.join(process.cwd(), "app/assets/builds"),
  plugins: [rails()],
  sourcemap: process.env.RAILS_ENV != "production"
}

async function buildAndReload() {
  // Foreman & Overmind assign a separate PORT for each process
  const port = parseInt(process.env.PORT || 3200)
  console.log(`Esbuild is listening on port ${port}`)
  const context = await esbuild.context({
    ...config,
    banner: {
      js: `
        (() => { 
          if (typeof EventSource !== 'undefined') { 
            new EventSource("http://localhost:${port}").onmessage = () => location.reload()
          }
        })();
      `,
    }
  })

  // Reload uses an HTTP server as an even stream to reload the browser
  http
    .createServer((req, res) => {
      return clients.push(
        res.writeHead(200, {
          "Content-Type": "text/event-stream",
          "Cache-Control": "no-cache",
          "Access-Control-Allow-Origin": "*",
          Connection: "keep-alive",
        })
      )
    })
    .listen(port)

  await context.rebuild()
  console.log("[reload] initial build succeeded")

  let ready = false
  chokidar
    .watch(watchDirectories)
    .on("ready", () => {
      console.log("[reload] ready")
      ready = true
    })
    .on("all", async (event, path) => {
      if (ready === false)  return

      if (path.includes("javascript")) {
        try {
          await setTimeout(20)
          await context.rebuild()
          console.log("[reload] build succeeded")
        } catch (error) {
          console.error("[reload] build failed", error)
        }
      }
      clients.forEach((res) => res.write("data: updatenn"))
      clients.length = 0
    })
}

if (process.argv.includes("--reload")) {
  buildAndReload()
} else if (process.argv.includes("--watch")) {
  let context = await esbuild.context({...config, logLevel: 'info'})
  context.watch()
} else {
  esbuild.build(config)
}

1

You can add more logging for TailwindCSS with the –verbose flag to check if any errors are happening that you can’t see.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>$ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch --verbose
</code>
<code>$ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch --verbose </code>
$ tailwindcss --postcss --minify -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --watch --verbose

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật