Vite className autoprefixer

861 Views Asked by At

I'm trying to add prefix to each className.

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import prefix from './prefix.plugin';

export default defineConfig({
  plugins: [prefix(), react()],
});
export default function () {
  return {
    name: 'prefix-classname',

    transform(code) {
      return code.replace('bg-red-900 w-40 h-40', 'tw-bg-red-900 tw-w-40 tw-h-40');
    },
  } as Plugin;
}

(tailwind.prefix = "tw-")

Here I add prefix, but in build all tailwind classes doesn't exist. What did I do wrong?

0

There are 0 best solutions below