postcss-load-config icon indicating copy to clipboard operation
postcss-load-config copied to clipboard

Typescript paths alias doesn't resolve

Open howagain opened this issue 1 year ago • 3 comments
trafficstars

Trying to use a shared tailwind config in an integrated Nx monorepo. The module resolution is all done with typescript path aliasing rather than package manager workspace module resolution. The shared tailwind config works just fine if I do a relative import ../../libs/shared-tailwind-config.ts but fails with a module failed to resolve if I have a path alias in my tsconfig of @tw: [/libs/shared-tailwind-config.ts]. I have included the postcss.config.ts file in my tsconfig.josn and VS code is able to recognize the import alias correctly in the file.

howagain avatar Jul 16 '24 08:07 howagain

What are you using for TS support? jiti or tsx? tsx supports tsconfig paths, jiti supports custom JITI_ALIAS format.

brc-dd avatar Jul 16 '24 09:07 brc-dd

Vite, so esbuild I believe.

On Tue, Jul 16, 2024 at 3:04 AM Divyansh Singh @.***> wrote:

What are you using for TS support? jiti or tsx?

— Reply to this email directly, view it on GitHub https://github.com/postcss/postcss-load-config/issues/266#issuecomment-2230390371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOELQY3LDYPXUPTX7KHOGJ3ZMTOZ3AVCNFSM6AAAAABK6EB3UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZQGM4TAMZXGE . You are receiving this because you authored the thread.Message ID: @.***>

howagain avatar Jul 16 '24 17:07 howagain

Vite is using v4 of this module -- ts-node stuff. Install ts-node and tsconfig-paths and configure it in your tsconfig.json - https://typestrong.org/ts-node/docs/paths


Here is a working example if you wanna try that out - https://stackblitz.com/edit/vitejs-vite-htrwaq?file=tsconfig.json,postcss.config.ts,src/foo.ts&terminal=dev

With vite 6, you'll be able to do this without any extra configuration. You'll just need to install tsx instead of ts-node.

The issue can probably be closed here.

brc-dd avatar Jul 16 '24 17:07 brc-dd