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 'base' option is ignored for the wasm output path #6

Closed
maccesch opened this issue Apr 13, 2021 · 7 comments
Closed

Vite 'base' option is ignored for the wasm output path #6

maccesch opened this issue Apr 13, 2021 · 7 comments

Comments

@maccesch
Copy link

Our clients runs the app we're writing on some subfolders. So we have set the base config option in Vite to './' but the wasm file is still loaded from the root '/our_wasm_bg.xxxxx.wasm'. We tried to set base = '/test/' but the wasm file is referenced absolutely without that.

@lencx
Copy link
Member

lencx commented Apr 14, 2021

This problem is fixed in the v1.2.8 (#4)version, please try again after upgrading.

vite doc: https://vitejs.dev/config/#base

Base public path when served in development or production. Valid values include:

  • Absolute URL pathname, e.g. /foo/
  • Full URL, e.g. https://foo.com/
  • Empty string or ./ (for embedded deployment)

@maccesch
Copy link
Author

That was fast! Thanks, man!

@sauloco
Copy link

sauloco commented Apr 15, 2021

The new 1.3.0 gives me the next output:
[rsw::error] wasm-pack for crate wasm failed

But if I downgrade to 1.2.7 works ok.

I've been diving through the code and looks like root and crate paths aren't pointing to the actual path bc of an issue. Please consider checking my suggestion in #7

@lencx
Copy link
Member

lencx commented Apr 15, 2021

@sauloco Please install version v1.3.1, try again.

@sauloco
Copy link

sauloco commented Apr 15, 2021

Already tested, working ok and delivered. 👌🏻
Thanks so much for your help!

@maccesch
Copy link
Author

maccesch commented Apr 18, 2021

in 1.3.1 it seems that absolute base paths work but not relative. When I have base: '/dist/' it works but when I have base: './' then although the build log indicates everything is correct in the browser it still tries to load from /assets/xxxx_bg.wasm

@maccesch maccesch reopened this Apr 18, 2021
@lencx
Copy link
Member

lencx commented Apr 19, 2021

@maccesch, I tried this seems to be ok.
yarn build --base "./"

build

<!-- dist/index.html -->
<script type="module" crossorigin src="./assets/index.21e4292b.js"></script>
<link rel="modulepreload" href="./assets/vendor.77fab89d.js">
<link rel="stylesheet" href="./assets/index.41fe33df.css">
// dist/assets/chasm.f9b73bca.js
new URL("./assets/rsw~chasm_bg.7b76064a.wasm",location.origin)

@lencx lencx closed this as completed May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants