2

I got a problem, i configured tailwind for my angular project in an NX workspace. When I use tailwind in libaries now, it is a strange behavior. I kind of know the problem already, but i have no solution right now. This is the Tutorial I used to set up tailwind. Initially all worked fine, but now it is kind of that the scss / tailwind from the libaries is not applied. Normally it should work, in the tutorial they wrote this:

In an Nx workspace, a regular library (non-buildable and non-publishable) is just a slice of an application that is only built as part of the build process of an application that consumes it. Because of that, as long as the application that consumes it has Tailwind CSS configured, the library code will be processed as expected even though the library itself doesn’t have a Tailwind CSS configuration. In fact, adding a tailwind.config.js file to the library won’t have any effect whatsoever (it’ll be ignored) because the library is never built on its own.

So i don't know why it is not working. At the moment i have a bad workaround. I copy the html code from the libary in the project and after it has compiled, I delete it and the tailwind configuration gets applied to the libary.

So how can i make sure that the tailwind is applied to the libaries, without copying the code.

style.scss, have the 3 imports: @tailwind base; @tailwind components; @tailwind utilities;

tailwind.config.js:

const { join } = require('path');

module.exports = {
  content: [
    join(__dirname, '/src/**/!(*.stories|*.spec).{ts,html}'),
    ...createGlobPatternsForDependencies(__dirname),
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
prantto
  • 21
  • 1

1 Answers1

-1

createGlobPatternsForDependencies can identify your app's dependencies and return the global pattern for them.

  1. You should check if your library is non-buildable and non-publishable
  2. Maybe you should build again.
Ray
  • 1
  • 1
  • Welcome to SO! As it is currently written, your answer is unclear. Please edit it and add more details about why and how it works. You can find out more at our ["How to write a good answer"](https://stackoverflow.com/help/how-to-answer) page. – ahuemmer Dec 10 '22 at 09:41
  • Could you improve your response please? – Joffrey Hernandez Mar 02 '23 at 13:52