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

Add ability to override __vitePreload chunk naming politics for SSR #8314

Closed
4 tasks done
the-illarionov opened this issue May 24, 2022 · 1 comment
Closed
4 tasks done

Comments

@the-illarionov
Copy link

the-illarionov commented May 24, 2022

Clear and concise description of the problem

I've made lean versions of my chunks, without static VNodes (MyModule.js -> MyModule.lean.js), exactly like you did in VitePress.
But i can't override vite's logic of naming chunks.

Right now i've figured out hacky solution using nginx:

location ~ (^(?!.*(lean|index)).*)\.js$ {
  if ($cookie_page_mode = "") {
	  return 302 https://localhost$1.lean.js;
  }
}

And on client:

window.addEventListener("beforeunload", () => {
	document.cookie = "page_mode=spa;max-age=-1"
})

router.beforeEach(() => {
	document.cookie = "page_mode=spa"
})

But it feels soooooo dirty.

Suggested solution

It would be great if i could write something like that in vite.config.js:

preloadPolitics: {
    javascript: chunkPath => {
         return initialVisit ? chunkPath.replace(".js",".lean.js") : chunkPath
    }
}

Alternative

No response

Additional context

No response

Validations

@the-illarionov the-illarionov changed the title Ability to override __vitePreload chunk naming politics Add ability to override __vitePreload chunk naming politics for SSR May 24, 2022
@sapphi-red
Copy link
Member

I think this can be now archived by #9938.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2022
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

2 participants