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

Vite ignores base: '' #1669

Closed
2 of 3 tasks
DreierF opened this issue Jan 23, 2021 · 3 comments
Closed
2 of 3 tasks

Vite ignores base: '' #1669

DreierF opened this issue Jan 23, 2021 · 3 comments

Comments

@DreierF
Copy link
Contributor

DreierF commented Jan 23, 2021

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

Setting base to an empty string is ignored by vite and it uses / instead. We need this as our app is deployed at varying base URLs that are unknown at build time.
I'm not entirely sure whether this works as intended or not as the docs don't explicitly mention this case. But it at least used to work up to 2.0.0-beta.37, but was probably broken by 809d4bd, while @vitejs/plugin-legacy still produces the expected path without / prefix.

Reproduction

Simply set base to '' in the config.

System Info

  • vite version: 2.0.0-beta.44
  • Operating System: MacOS
  • Node version: 14.15.4
  • Package manager (npm/yarn/pnpm) and version: yarn
@cawa-93
Copy link
Contributor

cawa-93 commented Jan 23, 2021

This also leads to build issues for the electron application, where the path to the files must be relative rather than absolute.

In the current version, no matter how hard you try, you can't get relative file paths:

// config.js
  base: './',
// index.html
<script type="module" crossorigin src="/./index.2cf5b0d7.js"></script>
<link rel="stylesheet" href="/./index.3855d19f.css">

Must be ./index.2cf5b0d7.js or index.2cf5b0d7.js

@yyx990803
Copy link
Member

Wouldn't a relative/empty base mess up asset references in CSS?

- dist
  - assets
    - foo.css -> url(./assets/foo.png)
    - foo.png

@DreierF
Copy link
Contributor Author

DreierF commented Jan 23, 2021

We have relativeUrls set to true in the less options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants