The `inject`/`injectProperty` settings aren't causing an object to be injected.
See original GitHub issueI’m trying to use the plugin with the following configuration.
new PrerenderSPAPlugin({
injectProperty: 'prerenderSettings',
inject: {
myProperty: true,
},
}),
My understanding of these settings is that window.prerenderSettings
should be set to { myProperty: true }
before rendering my pages during the build. My pages are otherwise prerendering correctly, but window.prerenderSettings
is undefined. I double checked this by adding the following code to my application.
document.body.innerHTML = `${document.body.innerHTML}<p id="prerender-settings">${window.prerenderSettings}</p>`;
After building with WebPack, the generated HTML includes a <p id="prerender-settings">undefined</p>
tag. To clarify, this is the raw HTML file that’s being output by prerender-spa-plugin
, I’m not opening the file in another web browser and causing a second tag to get injected.
This is with version 3.1.0.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Understanding Method Injection - Manning
This article delves into the Method Injection DI Pattern: how it works, and when and why you might want to use it.
Read more >Injecting Property Values Into Configuration Beans
Spring Framework has a good support for injecting property values found from properties files into bean or @Configuration classes.
Read more >What exactly is Field Injection and how to avoid it?
The reasons why field injection is frowned upon are as follows: You cannot create immutable objects, as you can with constructor injection ...
Read more >Dependency injection guidelines - .NET | Microsoft Learn
This article provides general guidelines and best practices for implementing dependency injection in .NET applications.
Read more >3.4.1.1 Constructor-based dependency injection - Spring
Configuration metadata can be specified via XML, Java code or annotations. For each bean, its dependencies are expressed in the form of properties,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @sangaline, prerender-spa-plugin 3.x introduces pluggable renderers with distinct features.
inject
is one such feature, so you need to configure it on the specific renderer rather than the root plugin config, like so:Hope that helps!
Noted. I’ll probably address it in the next update then. Thanks for the input!