vite-plugin-html-inject icon indicating copy to clipboard operation
vite-plugin-html-inject copied to clipboard

[Feature]: Define default replace values

Open G4PLS opened this issue 5 months ago • 2 comments

In the InjectHTMLConfig we have the replace field. This field currently only allows for undefined fields It would be awesome if we could define more than just this field.

As an example:

plugins: [injectHTML({
  replace: {
    undefined: "",
    version: "1.0.0"
  }
})]

This would now mean that if we have {=$version} somewhere and it is not defined we replace it with the default value.

G4PLS avatar Nov 09 '25 23:11 G4PLS

Perhaps it would be better to get that solved via ENV replacements (see #15)?

donnikitos avatar Nov 09 '25 23:11 donnikitos

I have never worked with vite ENV vars so I have no Idea how you define them. But if its as easy as: ENV VAR -> Replace then yeah that would totally do it!

How would the replacement actually work then, like how would I define "replace this"?

As an example: If I have the env var version Would it replace ={$version} or would I do <load src="..." version="%version%" />

G4PLS avatar Nov 10 '25 18:11 G4PLS