Is your feature request related to a problem? Please describe.
As the comment describes, when using directory mappings, the key must start and end with a slash
https://github.com/vitejs/vite/blob/e0acfdf395391df61db219fc928ba047b3aabe91/src/node/config.ts#L93-L113
Describe the solution you'd like
Since @/ -> src folder is a convention in vue-cli, it would be great to also add it to vite. It should be technically feasible because @/xx is not a valid npm package name.
Describe alternatives you've considered
Therer is another option: /@/, which matches the current rule.
+1
+1
My workaround is as follows:
const pathAliasMap = {
'@/': '/src/',
}
export default {
resolvers: [
{
alias(path: string) {
for (const [slug, res] of Object.entries(pathAliasMap)) {
if (path.startsWith(slug)) {
return path.replace(slug, res)
}
}
},
},
],
}
Most helpful comment
My workaround is as follows:
vite.config.ts