Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daveb2's avatar

Vite w/laravel 10: some tailwind css classes missing in production

For some reason the class lg:my-10 is compiling fine with npm run dev on development, but when I publish to live with npm run build that class is missing from the app-xxxxxxxx.css file.

I'm not very experienced with vite and I only have a rudimentary understanding of what it's doing. Can anybody point me in the direction of where to start troubleshooting here?

My /resources/css/app.css file contains:

@import '@fortawesome/fontawesome-pro/css/all.css';/* fontawesome */

@tailwind base;
@tailwind components;
@tailwind utilities;

I just can't work out why that class would be excluded; it's being used in a blade template with the line:

<div class="mx-auto sm:px-6 lg:px-8 lg:my-10">

There are no @if statements around it or anything like that. All the other classes are available, as far as I can tell - eg. lg:px-8 is there. It is just lg:my-10 which isn't being included.

npm view tailwind version returns 4.0.0 on both dev and production.

I'm a bit worried that vite isn't going to be reliable enough to use on production.

0 likes
5 replies
LaryAI's avatar
Level 58

It's possible that the lg:my-10 class is being purged by Tailwind during the production build. To fix this, you can add the class to the purge option in your tailwind.config.js file.

Here's an example of how to do this:

  1. Create a tailwind.config.js file in the root of your project if you haven't already.
  2. Add the following code to the file:
module.exports = {
  purge: [
    './resources/**/*.blade.php',
    './resources/**/*.js',
    './resources/**/*.vue',
  ],
  // ...other Tailwind options
}
  1. Add the lg:my-10 class to the purge array:
module.exports = {
  purge: [
    './resources/**/*.blade.php',
    './resources/**/*.js',
    './resources/**/*.vue',
    './resources/**/*.css', // add this line
  ],
  // ...other Tailwind options
}
  1. Rebuild your production assets with npm run build and check if the lg:my-10 class is now included in the output CSS file.

If this doesn't work, you can try disabling the purge option entirely in your tailwind.config.js file:

module.exports = {
  purge: false, // disable purge
  // ...other Tailwind options
}

Note that disabling purge will increase the size of your CSS file, so it's not recommended for production use.

2 likes
daveb2's avatar

Thanks ChatGPT. I will add to my reply then that the class is present in the built css file on dev that is created when I run npm run build (the file is in /public/build/assets/app-1b98xxxx.css) but it appears the contents of /public/build/assets/ on production are old, and are not being overwritten when I run my Envoy script. Seems like that is where I should look next.

daveb2's avatar

Hmm, it seems the default .gitignore setup excludes /public/build, where all of the live assets are built (on development) by vite (when I run npm run build).

So how should this work with vite: should I run npm run build on development, and then sync all of /public/build/assets to production, or should I run npm run build as part of my Envoy script to generate those assets on production?

daveb2's avatar

Pretty far down this rabbit hole now. Can't run npm run build on production because it's a cpanel server that seems to be running cloudlinux underneath, and I'm hitting all sorts of OS thread limits. Modifying available OS threads using ulimit -u or modifying /etc/security/limits.conf has no effect.

when I run npm run build I still see:

vite v4.3.3 building for production...
✓ 55 modules transformed.
runtime: failed to create new OS thread (have 13 already; errno=11)
runtime: may need to increase max user processes (ulimit -u)
fatal error: newosproc

followed by a few pages like

runtime stack:
runtime.throw({0x95da32?, 0xc000491e08?})
        runtime/panic.go:1047 +0x5d fp=0xc000491de0 sp=0xc000491db0 pc=0x4356dd
runtime.newosproc(0xc00028a000)
        runtime/os_linux.go:195 +0x176 fp=0xc000491e48 sp=0xc000491de0 pc=0x431f56
runtime.newm1(0xc00028a000)

So I guess I will have to build on dev and commit to git repo. I don't like that solution but I don't want to go all the way down the CI/CD rabbit hole just to solve this one stupid problem.

daveb2's avatar

So doing an npm run build locally, syncing to git, and doing a git pull on live (excluding /public/build from .gitignore so that those build files are published to git & live) works. Also, Envoy is great :)

1 like

Please or to participate in this conversation.