Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path mapping starting with "/" #97

Open
hyrious opened this issue Nov 12, 2020 · 0 comments
Open

path mapping starting with "/" #97

hyrious opened this issue Nov 12, 2020 · 0 comments

Comments

@hyrious
Copy link

hyrious commented Nov 12, 2020

maybe related: dividab/tsconfig-paths#128

Me recently work on an vite app which does not support path mapping starting with '@', instead it could use '/@' (vitejs/vite#279). However this extension can not handle these paths like "/@assets/aqua.png". I think it is caused by:

const segments = pathName.split('/');

Me locally make some dirty works by adding these code and it seems to be working fine:

if (!firstSegment && this.aliases.indexOf('/' + segments[1]) > -1) {
    segments.shift(); // shift ""
    let aliases = this.paths['/' + segments[0]];
    if (!Array.isArray(aliases)) aliases = [aliases];
    aliases.forEach((alias) => {
        if (alias.endsWith('/')) alias = alias.substring(0, alias.length - 1);
        segments[0] = alias;
        const resolvedPath = segments.join('/');
        pathsToTest.push(resolvedPath);
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant