Skip to content

Efficient imports without aliases #341

Answered by ElMassimo
jpriollaud asked this question in Q&A
Discussion options

You must be logged in to vote

Have in mind that you can always define your own aliases by using Vite's resolve.alias.

For example, in the repo you mentioned, you could use fs to list all directories in the root (such as components, assets, store), and define an alias for each, allowing to minimize changes to the code you are migrating.

See this gist for a similar approach that reads tsconfig.json and defines an alias for each alias that TypeScript is configured to understand.


I used aliases everywhere ( ~/ ) which worked fine, but felt wrong

This is the most robust approach though, as it's overall more compatible with other tools (like TypeScript).

You can use @/ if what feels wrong is the ~ symbol, or choose a dif…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jpriollaud
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants