Skip to content

Inconsistent asset paths between dev and build when using base #10217

@rottbers

Description

@rottbers

Describe the bug

Steps to reproduce

  1. Go to https://stackblitz.com/edit/vitejs-vite-jbosbq
  2. Run npm run build && npm run preview
  3. Check path for href attribute:
    <head>
      ...
      <link rel="icon" type="image/svg+xml" href="/admin/vite.svg">
      <link rel="manifest" href="/manifest.json"> 👈✅
      ...
    </head>
  4. Run npm run dev
  5. Check path for href attribute:
    <head>
      ...
      <link rel="icon" type="image/svg+xml" href="/admin/vite.svg">
      <link rel="manifest" href="/admin/manifest.json"> 👈❌
      ...
    </head>

In the example I'd expect asset paths in index.html to behave the same in development as when building for production - i.e. that the provided base (/admin/) only gets prefixed to assets found in public/ (i.e. vite.svg) and that paths for non-existing files (i.e. manifest.json) is left untouched.

Reproduction

https://stackblitz.com/edit/vitejs-vite-jbosbq

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 16.14.2 - /usr/local/bin/node
  Yarn: 1.22.10 - /usr/local/bin/yarn
  npm: 7.17.0 - /usr/local/bin/npm
npmPackages:
  vite: ^3.1.0 => 3.1.3

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: htmlinconsistencyInconsistency between dev & buildp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions