Closed seivan closed 2 years ago
The Idea of vite-aliases is to generate aliases based on your folder structure and create a js/ts config along side it, so you dont have define it at all.
Technically speaking, its pretty easy to extend with an existing tsconfig, but that kinda defeats the purpose of this package.
If i understand your proposal right..
This definition is it just in memory or one the file system? The problem would be that the type checker would complain if you don’t have it on tsconfig as well.
But if you need it there as well the file system then my guess is it would cause issues if they mismatch, am I wrong?
As the package runs every time you run your normal vite build/dev, the ts/js config gets rewritten same for the vite-aliases config. So there shouldnt be a mismatch.
Oh ok. Thanks for clarifying that.
In my case, I don't use path aliases. I just use
"baseUrl": "src",
So I can import from root.
Then all I needed was
So I thought I could just replace that line with the plugin. And have TSConfig be the source of truth.
But I think, you had a different idea? You would write to the TSConfig or make an in-memory version of it?
Can I suggest an alternative approach?
Make them mutually exclusive. The arguments either take (almost) all the
Omit<Options, 'tsconfig'>
it currently take, ortsconfigPath
.From TSConfig, you don't need to recursively loop through directories or all that jazz, the definitions are already made for you, things like
baseURL
andaliases
are defined by the user.This guy got the right idea.