Skip to content
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

Loading other config files #11

Open
TehGM opened this issue Mar 11, 2022 · 3 comments
Open

Loading other config files #11

TehGM opened this issue Mar 11, 2022 · 3 comments

Comments

@TehGM
Copy link

TehGM commented Mar 11, 2022

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 example wwwroot/appsettings.Prerendering.json);
  • any other manually specified config file (the approach like with Page not listed not getting pre-rendered #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.

@jsakamoto
Copy link
Owner

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.

@TehGM
Copy link
Author

TehGM commented Mar 12, 2022

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!

@jsakamoto
Copy link
Owner

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.

@jsakamoto jsakamoto mentioned this issue Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants