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

base option dont work in build in vite.config.js, if use in commend line like '--base=./' Hydration completed but contains mismatch #3984

Closed
4 tasks done
WuMianzhi opened this issue Jun 24, 2024 · 2 comments
Labels
need more info Further information is requested

Comments

@WuMianzhi
Copy link

Describe the bug

just like title decribe,
in vit.config.js i just set ssr optionnoExternal: ['packages'], base option does not work in product. In builded html file the js assets path is '/assets/jsfile.js' which should be /docs/assets/jsfile.js. And if i use --base='/docs/' the res path will add base url but when i put it on my server it dont work and shows Hydration completed but contains mismatch in my console

Reproduction

idk, it huge project, monorepo

Expected behavior

like dev when i put it in nginx

System Info

vitpress 1.2.3
pnpm: 9.4.0

Additional context

No response

Validations

@WuMianzhi WuMianzhi added the bug: pending triage Maybe a bug, waiting for confirmation label Jun 24, 2024
@Zhengqbbb
Copy link
Contributor

Provide a mini reproduction: https://vitepress.new/

/docs/assets/jsfile.js:

Hydration completed but contains mismatc:

  • The jsfile.js using Vue feature ?
  • If so, u need to loaded after Vue, like:
    import { inBrowser } from 'vitepress';
    import { onMounted } from 'vue';
    
    onMounted(async () => {
        if (inBrowser) {
            const a = await import('/asstes/jsfile.js')
        }
    });

@brc-dd brc-dd added need more info Further information is requested and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jun 25, 2024
@WuMianzhi
Copy link
Author

Provide a mini reproduction: https://vitepress.new/


/docs/assets/jsfile.js:

Hydration completed but contains mismatc:

  • The jsfile.js using Vue feature ?

  • If so, u need to loaded after Vue, like:

    import { inBrowser } from 'vitepress';
    
    import { onMounted } from 'vue';
    
    
    
    onMounted(async () => {
    
        if (inBrowser) {
    
            const a = await import('/asstes/jsfile.js')
    
        }
    
    });
    

thank you very much, I just found the base opt should write in file config.mts not in vit.config.ts thank you again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants