'Tailwind purge with Nx, no ProjectGraph error

The documentation here: https://nx.dev/l/r/guides/using-tailwind-css-in-react#introducing-nx-utility-for-better-tailwind-purging suggests to use createGlobPatternsForDependencies(__dirname) for ease of maintenance.

I am using this from '@nrwl/angular/tailwind', not '@nrwl/react/tailwind'.

When I use this and trigger a build of my app, I get the following errors:

[createGlobPatternsForDependencies] WARNING: There was no ProjectGraph available to read from, returning an empty array of glob patterns

Q: How can I resolve this?

I can run nx dep-graph and the dependency graph generates fine.

EDIT: I debugged this, and __dirname documentation says workspace relative directory path that will be used to infer the parent project and dependencies but then it fails later on line 20 of generate-globs.js because filenameRelativeToWorkspaceRoot is the '', i.e. its trying to find a project name but __dirname is the workspace name itself?

so

purge: createGlobPatternsForDependencies(join(__dirname, 'apps/simple-app')),

doesn't give the ProjectGraph error but

purge: createGlobPatternsForDependencies(__dirname), does



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source