简体   繁体   中英

Why are some Tailwind classes not having effect in JetStream?

Some classes like text-green-500 , rounded are having effect and the styling is updated.

Ohter classes, like bg-black , don't have any effect on the styling.

I am using Jetstream and TailwindCSS.

I have solve this problem before with this :

npm run prod

this might help you

There are plenty of possibilities which may cause this, but as a kind of a workaround you could use the safelist in the tailwind.config.js, as follows:

    purge: {

      content: [
     './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
    './vendor/laravel/jetstream/**/*.blade.php',
    './storage/framework/views/*.php',
    './resources/views/**/*.blade.php',
    ],
    safelist: [
        'rounded',
        'text-green-500',
    ],
},

and don't forget to run npm run dev.

ps for some reason, sometimes npm run dev is not enough and I have to go for npm run watch, and ctrl+c it after the mix recompile is over. Don't know what could the reason be, but it helped.

If you add some html with tailwind CSS elements not used before then just run 'npm run dev' and that should add the CSS classes.

After that, you can start the server using 'php artisan serve'

While you're developing run npm run watch , it will refresh the CSS requirements whenever you save a page.

npm run prod is for once you have finished developing and want to put the site into production.

As suggested by @DaviMendesDev you need to run npm to compile your classes for use.

npm run dev

or

npm run prod

this will generate .css files you can use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM