N
Nuxt3mo ago
Denish

Override default '#app' alias in Nuxt v4 alpha-2

hi, is it possible to override default '#app' alias in nuxt? since i want to keep import alias consistent with another, currently '#app' alias is reserved by nuxt and uses internally, so i want to use '#app' to resolve to 'app/' folder without breaking anything, and i want to remove default alias which is '~' and '~~' completely as vscode is making it as default choice when importing instead of using aliases. I am using nuxt v4 alpha, and i have following aliases, '#server' -> '$projectRoot/server/', '#core' -> '$projectRoot/core' , '#shared' -> '$projectRoot/shared'
5 Replies
kapa.ai
kapa.ai3mo ago
Hi @Denish. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources do not provide explicit information about overriding or removing the default #app alias in Nuxt v4 alpha, nor about fully removing the ~ and aliases. The documentation and related PRs confirm that these aliases are reserved and used internally by Nuxt, and while you can add custom aliases via the alias property in nuxt.config, there is no mention of being able to override or remove the built-in #app, ~, or aliases without potentially breaking internal functionality or encountering unsupported behavior. The docs do show how to add custom aliases and mention that the default aliases are automatically included in the generated tsconfig, but not how to remove or override the core ones like #app, ~, or ~~ Nuxt Configuration: alias. If you need to keep your import aliases consistent, you can add your own (such as #server, #core, #shared) and use them in your code, but the default Nuxt aliases will still exist. There is also no documented way to safely reassign #app to point to your app/ directory without interfering with Nuxt's internal usage. If this is a critical requirement, you may want to follow or open a feature request on the Nuxt GitHub repository, as this level of alias customization is not currently documented or officially supported. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@764519870393614347> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Denish
DenishOP3mo ago
@kapa.ai how to use 'prepare:types' hook in nuxt to modifyt the tsconfig, i want to remove '` and '~' alias from paths @kapa.ai how to use 'prepare:types' hook in nuxt to modifyt the tsconfig, i want to remove '` and '~' alias from paths
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry, but the knowledge sources do not provide explicit information or examples on using the prepare:types hook in Nuxt specifically to remove the ~ and aliases from the TypeScript paths in the generated tsconfig. The available documentation shows that you can use the prepare:types hook to inject or reference additional type files, but it does not detail how to modify or remove existing path aliases within the generated tsconfig using this hook. The recommended way to manage aliases is through the alias property in nuxt.config, but this does not cover removing the built-in ~ and aliases, which are reserved and used internally by Nuxt Nuxt Configuration: alias Adding Type Declarations. If you need more advanced control over the generated tsconfig, such as removing default aliases, this is not currently documented or officially supported in the knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@764519870393614347> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?