-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Can not dynamically import a raw file in production mode. #4252
Comments
current situation is glob pattern transformed by @rollup/plugin-dynamic-import-vars (./source/file*.md?raw) can't match any files, maybe you could work around this by using a js file which return markdown string. |
The problem originates from This plugin converts dynamic import expression with variables (which is not static) to string (say string Then glob with string But glob does not support You can visit here for the related code. The following is what this plugin would generate. I think @leon-kfd At this time, consider use vite-plugin-plain-text (which is included in the |
I have the same issue. +1 for supporting this in Vite and VitePress. |
duplicate of #3222 |
My temporary "solution" was to just fetch the content with a get and read it as text. As I'm fetching svg icons, I couldn't just use them as the const response = await fetch(`${this.CDN}/assets/icons/${this.icon}.svg`);
const text = await response.text();` |
Describe the bug
Can not dynamically import a raw file in production mode.
But it can work in dev mode.
Main code:

Run build & server, it happen:

Reproduction
https://github.com/leon-kfd/vite-dynamic-import-raw-file
Reproduction:
yarn
npm run build
npm run serve
Click load file button, will throw error in console.
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: