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

Dynamic import strange bugs #56

Open
websharik opened this issue Jul 23, 2023 · 1 comment
Open

Dynamic import strange bugs #56

websharik opened this issue Jul 23, 2023 · 1 comment

Comments

@websharik
Copy link

Ex1 (di in just js file):

let l = 'en' //'en.svg' work fine
let u = require(`@assets/img/flags/${l}.svg`) //'.svg' will loss
console.log(u)
Error: Failed to load url /src/assets/img/flags/ru (resolved id: /src/assets/img/flags/ru) 

Ex2 (di in vue component):

<img :src="require(`@assets/img/flags/${$i18n.locale}.svg`)"/>
Error: Cannot find module '' imported from...
42 |  import * as _vite_plugin_require_transform_os_ios_5 from "@assets/img/icons/os_ios.svg";
43 |  import * as _vite_plugin_require_transform_arrow_lang_6 from "@assets/img/icons/arrow_lang.svg";
44 |  import * as _vite_plugin_require_transform__7 from "";
   |                                                      ^
@websharik
Copy link
Author

const getFlagURL = locale => require(`@assets/img/flags/${locale}.svg`)
4  |  import * as _vite_plugin_require_transform__0 from "";
   |                                                      ^
5  |  const getFlagURL = locale => _vite_plugin_require_transform__0.default || _vite_plugin_require_transform__0;

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