Skip to content
Discussion options

You must be logged in to vote

The issue is that ?url doesn't actually prevent inlining when the file is under the assetsInlineLimit threshold. In dev mode, Vite serves everything as modules and the ?url suffix gives you a URL, but it's still processed through Vite's asset pipeline which can transform it.

Since your sprite is in /public, you shouldn't import it at all — files in public/ are served as-is and available at the root URL. Just reference it directly:

<template>
  <svg>
    <use href="/svg_sprite.svg#logo"></use>
  </svg>
</template>

No import needed. The /public/svg_sprite.svg file is served at /svg_sprite.svg by both the dev server and the production build. This avoids the entire inlining/bundling pipeline.

T…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Kilkenni
Comment options

Comment options

You must be logged in to vote
1 reply
@Kilkenni
Comment options

Answer selected by Kilkenni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants