-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
Ability to control CSS and JS includes within HTML template #419
Comments
How about this? import { escapeInject, injectAssets, dangerouslySkipEscape } from 'vite-plugin-ssr'
export { render }
function render(pageContext) {
return escapeInject`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
${injectAssets(() => pageContext.pageAssets.filter(asset => asset.type==='style'))}
<title>Vite App</title>
</head>
<body>
<div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
${injectAssets(() => pageContext.pageAssets.filter(asset => asset.type==='script'))}
</body>
</html>`
} |
This would be perfect! |
…com/injectPreloadAssets (closes #262, closes #419, closes #420, closes #510)
https://vite-plugin-ssr.com/preload Released in In case your company is up for it: https://github.com/sponsors/brillout. Some of what you said is still not possible though.
Why?
What's a use case for that? I originally went for the design of my previous comment, but it didn't work out for various reasons. |
Description
It would be nice to fine tune the positioning of asset includes within the HTML.
As a front-end developer, I want to be in charge, in very fine detail, where specific tags are included. Currently all CSS is prepended to the
<head>
and scripts appended to<body>
.In the case of CSS, the CSS its standard practice to be at least included after a charset meta tag.
In the case of Javascript, there could be blocking scripts that need to be included after the vite compiled injections.
Currently, we currently doing this via a "post-build" script that loops over all the statically generated files - but this is not suitable for any pages using SSR.
Suggestion
A template tag (e.g.
{{CSS_PLACEHOLDER}}
{{JS_PLACEHOLDER}}
) that can be utilised within the templates and if they do not exist, fall back to current implementation.The text was updated successfully, but these errors were encountered: