-
Notifications
You must be signed in to change notification settings - Fork 63
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
Transform/Manipulate index html before sending it #926
Comments
I'm on the same position. @Kuirak do you found a solution? |
I have successfully set up your patch @Kuirak with
|
I'm in the same boat, @dtslvr . Were you able to get it running? |
I tinkered with it a bit - it doesn't work because renderFn isn't called after you call espress.static() This isn't what you'd check into the repo, but this got me past the issue --
|
No, but I'm going with a solution @geongeorge has suggested using an express middleware. Something like this:
and
|
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
Expose a function to transform the
index.html
before sending it to the client to inject some variables or replace certain parts, without setting up a completeview engine
setup.Describe the solution you'd like
It would be great to expose a function
transformIndexHtml?: (indexHtml: string)=> string | Promise<string>
With this function any transform can be handled.
Here is the diff file I use to
patch-package
this feature in our code base:Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
We want to inject a variables into the
index.html
before sending it to the client. In our case we want to replace the<base href="/"/>
with the correctbaseUrl
in case the application runs on a pathname e.g.http://localhost:3001/app
. Additionally we want to set a variable on thewindow
object. We don't want to setup the whole view engine and install something likeejs
to do these simple transformations.The text was updated successfully, but these errors were encountered: