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

fix(create-vite): fix broken vite logo when base changed #12374

Merged
merged 2 commits into from
Mar 12, 2023

Commits on Mar 11, 2023

  1. fix(create-vite): fix broken vite logo in react when base changed

    After using create-vite to generate a React project, in a production build the Vite logo will break when setting the base URL to anything except the default `/`.
    
    This occurs because the `img` `src` directly refers to the generated `/vite.svg` and React does not preprocess `src` attributes to add the configured `base`.
    
    As suggested in vitejs#7358 (found via vitejs#10601), the solution is to import `vite.svg` in the same way as `react.svg` already is. This MR implements that solution in to the templates to prevent confusion in the future.
    
    Note: If using `npm run dev` from the generated `package.json`, the issue will not show up. However, the issue will show up when using `npm run build` followed by `npm run preview`.
    
    ```shell
    npm run build -- --base /test
    npm run preview -- --base /test
    
    npm run dev -- --base /test
    ```
    XanderXAJ committed Mar 11, 2023
    Configuration menu
    Copy the full SHA
    fcda743 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8281c0f View commit details
    Browse the repository at this point in the history