1

In my index.css I have these annotations:

@import "tailwindcss" prefix(tw) source(none);
@source "../content_script";

Generated CSS file has styles with names that are not under content_script and not anywhere in my project

@layer base {
  *, :after, :before, ::backdrop {
    box-sizing: border-box;
    border: 0 solid;
    margin: 0;
    padding: 0;
  }

  ::file-selector-button {
    box-sizing: border-box;
    border: 0 solid;
    margin: 0;
    padding: 0;
  }
  
  /* ... */
}
/* ... */

How to get rid of unnecessary generated styles? Have them not be generated at all?

1
  • It's much better that you highlighted this in a separate question. This way, it's clearly visible that you want to remove TailwindCSS's "reset" styles. These resets are responsible for removing default margins, paddings, borders, outlines, etc. from elements, so you can build your styles from a clean, zero-formatting base. Commented Apr 12 at 7:40

2 Answers 2

1

Those styles are from Tailwind's preflight:

An opinionated set of base styles for Tailwind projects.

You can remove them as per the documentation:

Remove:

@import "tailwindcss";

And replace with:

@layer theme, base, components, utilities;

@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/utilities.css" layer(utilities);
Sign up to request clarification or add additional context in comments.

Comments

0

Actually, Wongjn described exactly what you need; but it's neither mentioned in the documentation nor here that, in order to preserve prefix() and source(), you need to include them in both imports.

@layer theme, base, components, utilities;

@import "tailwindcss/theme.css" layer(theme) prefix(tw);
@import "tailwindcss/utilities.css" layer(utilities) source(none);

@source "../content_script";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.