Closed ivarlovlie closed 2 years ago
Hey there!
Checked the repro, getting the same issue here! Could you post a log of the generated vite-aliases here? That would be great!
The issue might be attached to the basepath, as its technically taking the directory where the config is located and then adds the relative path to the related folder.
setup:
ViteAliases({
prefix: "$",
useTypescript: true,
useConfig: true,
createLog: true
}),
logs:
[
{
"find": "$components",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src/components"
},
{
"find": "$lib",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src/lib"
},
{
"find": "$logs",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src/logs"
},
{
"find": "$pages",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src/pages"
},
{
"find": "$styles",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src/styles"
},
{
"find": "$",
"replacement": "/home/ivar/s/repos/time-tracker/src/webapp/src"
}
]
paths in tsconfig.json:
"paths": {
"$components/*": [
"./src/webapp/src/components/*"
],
"$lib/*": [
"./src/webapp/src/lib/*"
],
"$pages/*": [
"./src/webapp/src/pages/*"
],
"$styles/*": [
"./src/webapp/src/styles/*"
],
"$/*": [
"./src/webapp/src/*"
],
"$logs/*": [
"./src/webapp/src/logs/*"
]
}
Hm, try setting the default directory for vite-aliases, this might solve the issue actually.
ViteAliases({
dir: `src/webapp`
})
If that doesnt work, i know where the code issue actually is. As its checking for the path based on the dir, and the default dir is set to src
which in your case is doubled, and it cant handle that case.
@ivarlovlie Did this work for you?
closed due to inactivity
Had this same issue, solved it by setting dir
to ./src
:
ViteAliases({
dir: "./src"
})
Say I have a vite project inside of
./src/app22/vite.config.js
and all of my code for app22 is inside of./src/app22/src/
. The generated aliases for vite works as expected, but when writing aliases to tsconfig an alias for$pages/index
for example would look like./src/app22/src/pages/*
instead of what would be expected (?)./src/pages/*
. If I rename the firstsrc
tonotsrc
for example this is the behaviour I get.I have attached a repro, just install deps and build with vite.
repro.zip