Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TailwindCSS Autoprefixer not working | flex

Hi I used tailwind in my react project but when I build the project, the autoprefixer doesn't work properly

tailwind.config.js:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,js}"],
  theme: {
    container: {
      center: true,
      padding: "1rem",
    },
    extend: {},
    },
  },
  plugins: [
     require('autoprefixer')
  ]
};

I wanna autoprefixer work for every flex property like:

.flex{
    display: flex;
}

to

.flex{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

browserslist package.json:

{
  ....

  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },

  ...
}

I want all flex properties to work in all browsers, because, for example, on an old phone in the Safari browser, the gap property does not work correctly.

like image 259
Emma Teylor Avatar asked Oct 19 '25 20:10

Emma Teylor


1 Answers

First, you need install PostCSS and setup like here:

Installing Tailwind CSS as a PostCSS plugin is the most seamless way to integrate it with build tools like webpack, Rollup, Vite, and Parcel. Tailwind documentation

And second step, reduce the percentage of support from >0.2% to >0.01% in both enviroments.

browserslist package.json:

{
  ....

  "browserslist": {
    "production": [
      ">0.01%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      ">0.01%",
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },

  ...
}

enter image description here

Finnaly, you can remove the autoprefixer plugin from tailwind.config.js .

like image 192
Anton Avatar answered Oct 22 '25 13:10

Anton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!