-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Dynamic import fails with variables and aliases #10460
Comments
It looks like this plugin will solve your problem |
@Dunqing Thanks for the share but this does not actually help as it in somehow transforms it to relative paths. looking for something similar to how CRA handle it |
Any update about this |
Hey any update here? |
@harshithmullapudi Nope, but i've worked with relative paths to resolve this issue, so absolute paths with dynamic imports won't work. If you're facing a similar situation here, i may help. |
Any updates here? This works:
but this doesn't
|
I think dynamic imports with variables have to start with "./" or "../" and also include the file ending. |
const aliases = {
- apps: "/src/apps",
+ apps: path.join(__dirname, "/src/apps"),
}; Because |
Possible that this plugin vite-plugin-virtual-resource could do the job. |
Describe the bug
I added in
vite.config.ts
aliases list as followsNow when i try to make a dynamic import like this
This works fine, but when i try to do something like this, it does not work at all
See the example for reproducing.
Any idea on how to make this works.
Thanks
Reproduction
https://codesandbox.io/s/angry-snyder-7vsypo?file=/src/main.tsx
Steps to reproduce
No response
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: