-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Got wrong url when importing some svg files #18034
Comments
There is a config about img convert |
Thanks @PengBoUESTC It is indeed related to this configuration, setting to 0 solves the problem. But what puzzles me is that I found 3 parameters for importing files in For some files, I want to explicitly import them using inline or url, instead of automatically processing it by size. The other side is that this behavior is not uniform in dev mode and prod mode, which can lead to issues that are difficult to troubleshoot in dev mode and are only discovered after going prod. declare module '*?raw' {
const src: string
export default src
}
declare module '*?url' {
const src: string
export default src
}
declare module '*?inline' {
const src: string
export default src
} |
first of all : there is a default assets file test about assetsInclude(file: string) {
return DEFAULT_ASSETS_RE.test(file) || assetsFilter(file)
} so that if u didn't use and then , I notice that export async function fileToUrl(
id: string,
config: ResolvedConfig,
ctx: PluginContext,
): Promise<string> {
if (config.command === 'serve') {
return fileToDevUrl(id, config)
} else {
return fileToBuiltUrl(id, config, ctx)
}
} last, I think that |
@PengBoUESTC I totally agree with you that Data URLs are also a type of URLs. Now there are only two final questions:
So far |
1: maybe a assetsInlineLimit: (id) => {
return id.includes('01')
} 2: not sure about this +_+ |
I'm facing the same issues of Vite inlining SVGs that are imported as
Kind of, yes, but it is not universally usable (e.g. you can't plug it into |
This inconsistency is not ideal and svg especially seems to have an issue #14815, so we decided to bring svg inlining during dev as well for consistency.
For this, there's a PR to disable inline using a new query #15454 |
Describe the bug
This problem only occurs in prod mode.
There are two svg files in reproduction that are imported in the same way, but get different results
Reproduction
https://github.com/hungtcs/vite-svg-assets-reproduction/blob/master/src/main.tsx
Steps to reproduce
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: