nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.83k stars 2.38k forks source link

Using 'createGlobPatternsForDependencies' in tailwind.config.ts does not resolve {projectRoot} token #22721

Closed PPan1215 closed 1 month ago

PPan1215 commented 7 months ago

Current Behavior

We are using tailwindcss in our nx projects, and the project.json file looks like below:

{
  "implicitDependencies": ["lib1", "lib2"],
  "name": "app1",
  "projectType": "application",
  "sourceRoot": "{projectRoot}/src", <- here
  "tags": [],
  "targets": {
   }
...
}

When we are configuring tailwind using createGlobPatternsForDependencies

import { createGlobPatternsForDependencies } from "@nx/react/tailwind"
import type { Config } from "tailwindcss"

export default {
  content: [
    join(__dirname, "src/**/*!(*.stories|*.spec|*.test).{ts,tsx,html}"),
    ...createGlobPatternsForDependencies(__dirname),
  ],
...
}

It throws an error:

WARNING: There was an error creating glob patterns, returning an empty array
createGlobPatternsForDependencies: Error when generating globs.
ENOENT: no such file or directory, scandir '/path/to/nx/{projectRoot}'

Expected Behavior

When sourceRoot in project.json file is {projectRoot} token, it should resolve to its correct path.

GitHub Repo

No response

Steps to Reproduce

You can simply replace sourceRoot with {projectRoot}/src in this example, and then use createGlobPatternsForDependencies from "@nx/react/tailwind" it should error out.

Screenshot 2024-04-08 at 3 54 47 PM

Nx Report

Node   : 18.17.1
   OS     : darwin-arm64
   pnpm   : 8.6.5

   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/jest           : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/esbuild        : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nx/node           : 18.0.4
   @nx/react          : 18.0.4
   @nx/storybook      : 18.1.2
   @nx/vite           : 18.0.4
   @nx/web            : 18.0.4
   @nx/webpack        : 18.0.4
   typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

pnpm - 8.6.5

Operating System

Additional Information

No response

PPan1215 commented 7 months ago

The sourceRoot here has simply read a plain text without being parsed.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 day ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.