BlazorWasmPreRendering.Build
BlazorWasmPreRendering.Build copied to clipboard
Loading other config files
Hey, me yet again!
Currently the package loads wwwroot/appsettings.json when pre-rendering. This is absolutely fine for majority of scenarios, and in general, is good enough.
However I was thinking - it'd be nice if it'd be possible to load additional config files (IF they exist - cause they might not!), like:
wwwroot/appsettings.<environment>.json(for examplewwwroot/appsettings.Prerendering.json);- any other manually specified config file (the approach like with #8 would be absolutely good enough).
The reason for first is that having different settings during prerendering stage could actually be useful in some scenarios.
The reason why I want to do second is that I want to split some files, because they'll contain a lot of content.
In my case loading other files than json is not needed at all, but could be quite handy when it comes to library flexibility - if it doesn't add too much complexity, of course.
This suggestion absolutely is not a pressing matter, as these things can be worked around - but it'd definitely be a nice-to-have when you have time to add them.
Fortunately, you can do that already!
If there is the wwwroot/appsettings.Prerendering.json, it will be loaded and override the wwwroot/appsettings.json.
That feature is provided by ASP.NET Core standard way, not by this package.
That means the file name of the custom application settings file that will be loaded depends on the name of the hosting environment.
By default, the hosting environment name will be "Prerendering" during the prerendering process is running.
Please see also the "Hosting Environment" section of the README.
- https://github.com/jsakamoto/BlazorWasmPreRendering.Build#hosting-environment
Yes, you're right. When I did it previously, it seemed like it didn't work - but I just created a test page + options to test this specifically, and it works. My bad, but happy about being wrong in this case!
What do you think about possibility to add files with different naming? Let's say I wanted to split appsettings.json into appsettings.json + verbs.json?
As mentioned previously, this is definitely not a pressing matter as can be worked around (or would simply not cause a problem in general) - but if you had capacity to do so, it could make a nice addition!
When I did it previously, it seemed like it didn't work
That's right, and application setting support has been started from v.1.0.0-preview.13, Dec 2021, about three months ago. :)
What do you think about possibility to add files with different naming?
Currently, I don't have a plan to implement that feature directly. However, it might be realized as a side effect of another future improvement of this package.