Skip to content

Setting multiple selectors in the same CSS rule returns an unexpected resultΒ #13

@fazdiu

Description

@fazdiu

Setting multiple selectors in the same CSS rule returns an unexpected result: For example:

import { TailwindConverter } from 'css-to-tailwindcss';
import postcssNested from "postcss-nested";

const converter = new TailwindConverter({
  remInPx: 16, // set null if you don't want to convert rem to pixels
  postCSSPlugins: [postcssNested], // add any postcss plugins to this array
  tailwindConfig: {
    // your tailwind config here
    content: [],
    theme: {
      extend: {
        colors: {},
      },
    },
  },
});

const inputCSS = `
.test{
  color:red;

  &:hover, &:focus{
    color: blue;
  }
}`;

converter.convertCSS(inputCSS).then(({ convertedRoot, nodes }) => {
  console.log(convertedRoot.toString());
});

Obtained result:

.test {
  @apply text-[red];
}
.test:hover,
.test:focus {
  @apply text-[blue];
}

Expected result:

.test {
  @apply text-[red] focus:text-[blue] hover:text-[blue];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions