QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.84k stars 1.31k forks source link

[🐞] qwik-city: vite base doesn't work in dev mode #5984

Closed wmertens closed 4 months ago

wmertens commented 8 months ago

Which component is affected?

Qwik City (routing)

Describe the bug

When you set config.base of vite, the build correctly uses it but dev mode breaks, getting module files without the base path.

Reproduction

https://stackblitz.com/edit/qwik-starter-wvwual?file=vite.config.ts

Steps to reproduce

try clicking Home

System Info

stackblitz, 1.5.1

Additional Information

No response

wmertens commented 8 months ago

Workaround: In your vite config, use

export default defineConfig(({command, mode}) => {
    return {
        base: command === 'build' ? '/your-base/' : undefined,
// ...
JerryWu1234 commented 8 months ago

let me pick this up.,

JerryWu1234 commented 8 months ago

image you say this bug ?

wmertens commented 8 months ago

@JerryWu1234 yes it should use the import.meta.env.BASE_URL in front of it

JuanmaVargas commented 5 months ago

In production, is there any workaround to fix this? I'm trying to create a multi-zone in Next.js for a Qwik application, and for that, I need the vite.base set in the configuration to work for all the assets

wmertens commented 5 months ago

@JuanmaVargas do you mean it's not working in production?

I have the fix for dev in #6326 but it's part of a rewrite. I hope to land it soon.

JohnPremKumar commented 5 months ago

Meantime if anyone looking for workaround set different path production and development:

export default defineConfig(() => {
  return {
    base: process.env.NODE_ENV === 'production' ? `/production-path/` : '',
    plugins: [
      qwikCity(),
      qwikVite(),
      tsconfigPaths(),
      vanillaExtractPlugin(),
    ],
  };
});
wmertens commented 4 months ago

I believe this to be fixed in 1.7.1. There are still some problems with windows though, see #6676