sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
17.8k stars 1.78k forks source link

Add a `%svelte.version%` template placeholder to propagate the current `kit.version.name` to app.html #12130

Open potch opened 1 month ago

potch commented 1 month ago

Describe the problem

We use git SHA for our versions across our apps, and pass those versions to third-party analytics services like Datadog. Several of these providers can be largely configured as static <script> tags in our app.html, but we'd like to be able to include the current version as well.

Describe the proposed solution

We're passing the version string as recommended in the version docs and would like if that version string was available as an HTML placeholder, e.g. %svelte.version%.

Alternatives considered

We've looked at doing our own HTML templating as part of hooks.server, as well as duplicating the version string into PUBLIC_VERSION which we could then access via %svelte.env.PUBLIC_VERSION% but if it's reasonable/straightforward to propagate the version via template placeholders it would be great ergonomics

Importance

nice to have

Additional Information

No response

Conduitry commented 1 month ago

Is there a reason to do this via an app.html template replacement as opposed to a tag inserted by a top-level +layout.svelte file?

potch commented 1 month ago

Is there a reason to do this via an app.html template replacement as opposed to a tag inserted by a top-level +layout.svelte file?

Usually third-party script includes are otherwise static and not "application aware", but in general it's an ergonomic convenience.