Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Nesting tailwind withing a .tailwind div to avoid conflicts #294

Open
Joeldorne opened this issue Jul 8, 2019 · 3 comments
Open

Nesting tailwind withing a .tailwind div to avoid conflicts #294

Joeldorne opened this issue Jul 8, 2019 · 3 comments

Comments

@Joeldorne
Copy link

How can I achieve compiling the following with Postcss? I know to avoid conflict I can use the prefix which I'm currently doing but I also want to wrap the project in the .tailwind class so I won't have conflicts with elements such as H1. I also want to write a custom base that overwrites the previous projects base styles. I managed to do this with gulp but it broke the responsive tags. I would like to not use gulp in the project.

.tailwind {
  /* Tailwind base */
  @import './node_module/tailwindcss/base';

  /* Custom base */
  @import './components/base';

  /* Tailwind components */
  @import 'tailwindcss/components';

  /* Custom components */
  @import './components/buttons.css'; 

  /* Tailwind utilities */
  @import 'tailwindcss/utilities';
}
@tehpsalmist
Copy link

tehpsalmist commented Jul 8, 2019

Since you're doing so much custom stuff, why not just remove @tailwind base?

@benface
Copy link

benface commented Jul 8, 2019

Related: tailwindlabs/tailwindcss#797

@adamwathan
Copy link
Member

Not being able to use import statements nested in a selector like this is unfortunately a limitation of postcss-import and not really an issue with Tailwind.

If you only want to add the class prefix to Tailwind's classes (and not your own custom classes), you should be able to do this, assuming there are no import statements in the file:

.tailwind {
  @tailwind base;
  @tailwind components;
  @tailwind utilities;
}

This also assumes you are using postcss-nested or postcss-nesting to handle nesting.

Alternatively you could write your own PostCSS plugin that uses comments as markers or something to work around the postcss-import limitation, so you're CSS might look like this:

/* start-tailwind-prefix */

/* Tailwind base */
@import './node_module/tailwindcss/base';

/* Custom base */
@import './components/base';

/* Tailwind components */
@import 'tailwindcss/components';

/* Custom components */
@import './components/buttons.css'; 

/* Tailwind utilities */
@import 'tailwindcss/utilities';

/* end-tailwind-prefix */

Moving to our discussion forum since not an issue with Tailwind.

@adamwathan adamwathan transferred this issue from tailwindlabs/tailwindcss Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants