-
-
Notifications
You must be signed in to change notification settings - Fork 541
docs(nuxt): add tsconfig alias section and set componentDir to app/components/ui (Nuxt 4) #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
β¦ app/components/ui (Nuxt 4)
Docs feedback (Nuxt installation) β based on https://www.shadcn-vue.com/docs/installation/nuxt.html In a fresh Nuxt 4 + Tailwind v4 project, strictly following the page above, I hit a blocker during
Root cause
Minimal fix (Nuxt 4 /
|
Hi @huangjunsen0406 , the Nuxt team and the TypeScript team are against using baseUrl in tsconfig files PR I created needs to be tested, the pkg.pr.new is there, and instructions are also explained there for using shadcn-vue in Nuxt 4 or 3 Please, if you have time, go test it and give us feedback so we can merge that PR sooner |
Hi @sadeghbarati β Iβve tested as requested. Hereβs the report. Tested on Nuxt 4 + Tailwind v4 (with
Result
Docs suggestion
Refs: #1330 (pkg.pr.new CLI preview), #1384. ([GitHub]1) ![]()
|
Let me create a StackBlitz for you The aliases you add in root |
Hi, sorry for the late response β Iβve been swamped recently. Iβm unable to get your sample project running. I also tried re-running:
but still get βNo import alias found in your tsconfig.json.β {
"compilerOptions": {
"paths": {
"@/*": ["./*"],
"~/*": ["./*"]
}
}
} Could you please try creating a fresh Nuxt 4 project and following the steps here to verify? If the latest CLI still requires aliases in the root ![]() ![]() ![]() |
We are working on v4-docs, and we will open PR soon |
π Linked issue
Refs: #1330, #1384
β Type of change
π Description
Explain
Nuxt 4 defaults to the
app/
directory and commonly uses a roottsconfig.json
with project references only.The shadcn-vue CLI validates TS path aliases from
tsconfig.json/jsconfig.json
, so without explicitcompilerOptions.paths
, users can hit βNo import alias foundβ.Also, pointing
componentDir
at./components/ui
(Nuxt 3 style) can confuse Nuxt 4 users whose components live underapp/components/ui
.What this PR changes
tsconfig.json (aliases)
section (beforenuxt.config.ts
) showing explicitcompilerOptions.paths
:@/*
and~/*
mapped to project root.@/components/*
β./app/components/*
(Nuxt 4).nuxt.config.ts
, setshadcn.componentDir = './app/components/ui'
for Nuxt 4.nuxi prepare
(or mentionmkdir -p app/components/ui
) to avoid the βComponent directory does not exist β¦/components/uiβ warning.Why
Ensures
init
/add
pass alias validation and avoids confusing warnings for Nuxt 4 users.Forward-compatible with ongoing work to auto-detect tsconfig for Nuxt (#1330, #1384).
Tested
npx shadcn-vue@latest init
βnpx shadcn-vue@latest add button
βnpx nuxi prepare
β no warnings βπΈ Screenshots (if appropriate)
N/A (docs-only)
π Checklist
tsconfig
file detection based on the frameworkΒ #1330, fix: support TypeScript project references in Nuxt 4Β #1384)