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

SVG inlining broke in 5.2.2 #16229

Closed
7 tasks done
kkomelin opened this issue Mar 22, 2024 · 0 comments · Fixed by #16233
Closed
7 tasks done

SVG inlining broke in 5.2.2 #16229

kkomelin opened this issue Mar 22, 2024 · 0 comments · Fixed by #16233
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release

Comments

@kkomelin
Copy link

Describe the bug

In Vite 5.1.6 I used relative image paths for SVG images in the HTML template like this:

// src/index.html
<img
  src="./vite.svg"
  alt="Vite logo"
/>

which inlined the SVG to data url after build:

data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20aria-hidden='true'%20role='img'%20class='iconify%20iconify--logos'%20width='31.88'%20height='32'%20preserveAspectRatio='xMidYMid%20meet'%20viewBox='0%200%20256%20257'%3e%3cdefs%3e%3clinearGradient%20id='IconifyId1813088fe1fbc01fb466'%20x1='-.828%25'%20x2='57.636%25'%20y1='7.652%25'%20y2='78.411%25'%3e%3cstop%20offset='0%25'%20stop-color='%2341D1FF'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%23BD34FE'%3e%3c/stop%3e%3c/linearGradient%3e%3clinearGradient%20id='IconifyId1813088fe1fbc01fb467'%20x1='43.376%25'%20x2='50.316%25'%20y1='2.242%25'%20y2='89.03%25'%3e%3cstop%20offset='0%25'%20stop-color='%23FFEA83'%3e%3c/stop%3e%3cstop%20offset='8.333%25'%20stop-color='%23FFDD35'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%23FFA800'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20fill='url(%23IconifyId1813088fe1fbc01fb466)'%20d='M255.153%2037.938L134.897%20252.976c-2.483%204.44-8.862%204.466-11.382.048L.875%2037.958c-2.746-4.814%201.371-10.646%206.827-9.67l120.385%2021.517a6.537%206.537%200%200%200%202.322-.004l117.867-21.483c5.438-.991%209.574%204.796%206.877%209.62Z'%3e%3c/path%3e%3cpath%20fill='url(%23IconifyId1813088fe1fbc01fb467)'%20d='M185.432.063L96.44%2017.501a3.268%203.268%200%200%200-2.634%203.014l-5.474%2092.456a3.268%203.268%200%200%200%203.997%203.378l24.777-5.718c2.318-.535%204.413%201.507%203.936%203.838l-7.361%2036.047c-.495%202.426%201.782%204.5%204.151%203.78l15.304-4.649c2.372-.72%204.652%201.36%204.15%203.788l-11.698%2056.621c-.732%203.542%203.979%205.473%205.943%202.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505%204.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z'%3e%3c/path%3e%3c/svg%3e

In Vite 5.2.2 the images stopped displaying after build.
The new data url looks the following:

data:image/svg+xml,%253csvg%2520xmlns='http://www.w3.org/2000/svg'%2520xmlns:xlink='http://www.w3.org/1999/xlink'%2520aria-hidden='true'%2520role='img'%2520class='iconify%2520iconify--logos'%2520width='31.88'%2520height='32'%2520preserveAspectRatio='xMidYMid%2520meet'%2520viewBox='0%25200%2520256%2520257'%253e%253cdefs%253e%253clinearGradient%2520id='IconifyId1813088fe1fbc01fb466'%2520x1='-.828%2525'%2520x2='57.636%2525'%2520y1='7.652%2525'%2520y2='78.411%2525'%253e%253cstop%2520offset='0%2525'%2520stop-color='%252341D1FF'%253e%253c/stop%253e%253cstop%2520offset='100%2525'%2520stop-color='%2523BD34FE'%253e%253c/stop%253e%253c/linearGradient%253e%253clinearGradient%2520id='IconifyId1813088fe1fbc01fb467'%2520x1='43.376%2525'%2520x2='50.316%2525'%2520y1='2.242%2525'%2520y2='89.03%2525'%253e%253cstop%2520offset='0%2525'%2520stop-color='%2523FFEA83'%253e%253c/stop%253e%253cstop%2520offset='8.333%2525'%2520stop-color='%2523FFDD35'%253e%253c/stop%253e%253cstop%2520offset='100%2525'%2520stop-color='%2523FFA800'%253e%253c/stop%253e%253c/linearGradient%253e%253c/defs%253e%253cpath%2520fill='url(%2523IconifyId1813088fe1fbc01fb466)'%2520d='M255.153%252037.938L134.897%2520252.976c-2.483%25204.44-8.862%25204.466-11.382.048L.875%252037.958c-2.746-4.814%25201.371-10.646%25206.827-9.67l120.385%252021.517a6.537%25206.537%25200%25200%25200%25202.322-.004l117.867-21.483c5.438-.991%25209.574%25204.796%25206.877%25209.62Z'%253e%253c/path%253e%253cpath%2520fill='url(%2523IconifyId1813088fe1fbc01fb467)'%2520d='M185.432.063L96.44%252017.501a3.268%25203.268%25200%25200%25200-2.634%25203.014l-5.474%252092.456a3.268%25203.268%25200%25200%25200%25203.997%25203.378l24.777-5.718c2.318-.535%25204.413%25201.507%25203.936%25203.838l-7.361%252036.047c-.495%25202.426%25201.782%25204.5%25204.151%25203.78l15.304-4.649c2.372-.72%25204.652%25201.36%25204.15%25203.788l-11.698%252056.621c-.732%25203.542%25203.979%25205.473%25205.943%25202.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505%25204.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z'%253e%253c/path%253e%253c/svg%253e

An important note here is that in development the images are not inlined (added by relative paths) and continue to be displayed.

My Vite config:

import { defineConfig } from "vite";

export default defineConfig({
  server: {
    open: "/index.html",
  },
  build: {
    outDir: "../dist",
  },
  root: "src",
});

Reproduction

https://github.com/kometolabs/vite-tailwind-nojs-starter

Steps to reproduce

yarn && yarn build && yarn preview

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 24.89 GB / 30.98 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.8.1 - ~/.nvm/versions/node/v20.8.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v20.8.1/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.8.1/bin/npm
    pnpm: 8.15.2 - ~/.local/share/pnpm/pnpm
  Browsers:
    Chrome: 122.0.6261.111
  npmPackages:
    vite: ^5.2.2 => 5.2.2

Used Package Manager

yarn

Logs

No response

Validations

@bluwy bluwy added p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release and removed pending triage labels Mar 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants