How to setup absolute paths in NX.dev for monorepo

81 views Asked by At

I've setup two applications using NX.dev and now I want to create a library for my components. I want to copy over components from another project that are using absolute paths and I've noticed that NX complains saying they do not exist. I feel like I did the normal thing here and update the baseURL to src/lib in the tsconfig/json file. This did not work.

I then went on to add aliases to see if this worked instead but it did not:

  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/components/*": ["src/lib/components/*"],
      "@/core/*": ["src/lib/core/*"],
    },
    "jsx": "react-jsx",
    "allowJs": false,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "types": ["vite/client"]
  },

When I run nx build mylibrary it doesn't error. Using NX creates loads of different TSconfig files and I thought maybe one is overwriting the other so added this to all of them with no success.

Would love it if someone else knows how to fix this issue

0

There are 0 answers