XStatic change output directory for the static site

Hello everybody!

How can I change the output directory for XStatic?

Currently, the output is placed in the umbraco\Data\xStatic\output\1 folder.

I didn’t find any option to change the output directory in the XStatic config. A simple naming would be enough, so 1 would be replaced by my-static-site.

One more question: I’m using USync. So when I delete the database locally, if I re-set up the site, it will have all the documents, etc. Is there a way for XStatic, to keep the deployment targets (maybe a config in the appsettings?), so I don’t need to recreate the deployment targets, when resetting the site?

For the first question, I found a solution: I had to implement a custom StaticSiteStorer.

See: xStatic-for-Umbraco/Docs/Site Storers.md at master · Mulliman/xStatic-for-Umbraco · GitHub

Then add it to the Program.cs but remove the Automatic() call:

var xStaticBuilder = builder.Services.AddXStatic();

xStaticBuilder.GeneratorServiceBuilder
    .AddDefaultSiteRepository()
    .AddDefaultComponentLists()
    .AddDefaultExportTypeServices()
    .AddDefaultActionServices()
    .AddDefaultActions()
    .AddDefaultHtmlGeneratorServices()
    .AddDefaultJsonGeneratorServices()
    .AddDefaultImageCropServices()
    .AddDefaultAutoDeployServices();

builder.Services.AddSingleton<IStaticSiteStorer, CustomSiteStorer>();

xStaticBuilder.DeployServiceBuilder
    .AddDeployersAutomatically();

xStaticBuilder.DeployServiceBuilder
    .AddDeploymentTargetCreatorsAutomatically();

My CustomSiteStorer is basically AppDataSiteStorer, but with the modification that I replaced staticSiteId with my wanted subfolder name.