piljac1's avatar
Level 28

Tailwind styles not recompiling after watched Vue change

Hi guys! I hope you're well. So my problem is that when I'm trying to stylize Vue components, all classes that aren't already part of the compiled CSS do not work until I stop my npm run watch and restart it. I haven't encountered this issue in any past project, but here's our current Tailwind and Mix setup:

tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {
  mode: 'jit',

  purge: [
    './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
    './vendor/laravel/jetstream/**/*.blade.php',
    './storage/framework/views/*.php',
    './resources/views/**/*.blade.php',
    './resources/js/**/*.vue',
  ],

  theme: {
    extend: {
      fontFamily: {
        sans: ['Mulish', ...defaultTheme.fontFamily.sans],
      },
    },
  },

  plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/typography'),
  ],
};

webpack.mix.js

const mix = require('laravel-mix');

require('mix-tailwindcss');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
  .vue()
  .sass('resources/sass/app.scss', 'public/css')
  .tailwind()
  .webpackConfig(require('./webpack.config'));

if (mix.inProduction()) {
  mix.version();
}

Thanks in advance!

0 likes
2 replies
Snapey's avatar

I had this problem last week and I think all I did was update all js packages and then it was fine . I didn't investigate it any further

piljac1's avatar
Level 28

@Snapey Unfortunately, that did not help in my case. I also tried to downgrade Tailwind to 2.1.x, no luck. I was able to pinpoint the JIT mode as the culprit. I don't know what related config is not correct or if it is a Tailwind bug, but removing the JIT mode solves that issue temporarily. Of course, it is not a viable fix for JIT users, but we can personally live without it for now. However, if anybody can help me find a fix, it would be gladly appreciated because JIT's performance and versatility is a good addition nonetheless.

Please or to participate in this conversation.