melmoniry's avatar

Trouble with running tailwind

Hello, I've just installed tailwind using this documentation https://laravel.com/docs/8.x/mix#tailwindcss for some reason after running mix with tailwind, all my CSS that i already had is gone it becomes all words with no containers or anything. is there anything am missing? or it should behave this way?

note:- am using Laravel 8 PHP 8.1

0 likes
4 replies
chaudigv's avatar
chaudigv
Best Answer
Level 16

all my CSS that i already had is gone it becomes all words with no containers or anything. is there anything am missing? or it should behave this way?

You are not missing anything. And this is the way Tailwind sets up the project. Reason Preflight

Upon installing Tailwind, Preflight removes all of the default margins from elements like headings, blockquotes, paragraphs, etc. That is why you are seeing all words with nocontainer or anything.

@tailwind base; /* Preflight will be injected here */

@tailwind components;

@tailwind utilities;

You can disable preflight:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
     preflight: false,
    }
  }

Reason for setting up Preflight because each browsers have their own way of styling things. An input type text on Chrome will look different from Firefox, Opera and others. Preflight is a set of base styles for Tailwind projects that are designed to smooth over cross-browser inconsistencies and make it easier for you to work within the constraints of your design system.

I would suggest to update your old CSS to use Tailwind.

1 like
siangboon's avatar

perhaps make sure your existing css file not using the same file name as the the output file the default is app.css as after the npm run dev command it will override the file.

webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');


1 like

Please or to participate in this conversation.