Adding BundleJsCss as property on BtcPayServerOptions

This commit is contained in:
lepipele
2018-02-21 00:48:25 -06:00
committed by nicolas.dorier
parent fb736c0d0f
commit 7e09efb9a3
4 changed files with 16 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ namespace BTCPayServer.Configuration
Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray()));
PostgresConnectionString = conf.GetOrDefault<string>("postgres", null); PostgresConnectionString = conf.GetOrDefault<string>("postgres", null);
BundleJsCss = conf.GetOrDefault<bool>("bundlejscss", true);
ExternalUrl = conf.GetOrDefault<Uri>("externalurl", null); ExternalUrl = conf.GetOrDefault<Uri>("externalurl", null);
InternalLightningNode = conf.GetOrDefault<Uri>("internallightningnode", null); InternalLightningNode = conf.GetOrDefault<Uri>("internallightningnode", null);
} }
@@ -95,5 +96,10 @@ namespace BTCPayServer.Configuration
get; get;
set; set;
} }
public bool BundleJsCss
{
get;
set;
}
} }
} }

View File

@@ -39,6 +39,7 @@ namespace BTCPayServer.Configuration
} }
app.Option("--externalurl", $"The expected external url of this service, to use if BTCPay is behind a reverse proxy (default: empty, use the incoming HTTP request to figure out)", CommandOptionType.SingleValue); app.Option("--externalurl", $"The expected external url of this service, to use if BTCPay is behind a reverse proxy (default: empty, use the incoming HTTP request to figure out)", CommandOptionType.SingleValue);
app.Option("--internallightningnode", $"An internal lightning node which can be used without https requirement and easily configured by the admin (default: empty)", CommandOptionType.SingleValue); app.Option("--internallightningnode", $"An internal lightning node which can be used without https requirement and easily configured by the admin (default: empty)", CommandOptionType.SingleValue);
app.Option("--bundlejscss", $"Bundle javascript and css files for better performance (default: true)", CommandOptionType.SingleValue);
return app; return app;
} }

View File

@@ -184,10 +184,15 @@ namespace BTCPayServer.Hosting
}); });
// bundling // bundling
services.AddBundles(options =>
services.AddBundles();
services.AddTransient<BundleOptions>(provider =>
{ {
options.UseMinifiedFiles = Environment.GetEnvironmentVariable("BTCPAY_BUNDLEJSCSS") == "true"; var opts = provider.GetRequiredService<BTCPayServerOptions>();
options.AppendVersion = true; var bundle = new BundleOptions();
bundle.UseMinifiedFiles = opts.BundleJsCss;
bundle.AppendVersion = true;
return bundle;
}); });
return services; return services;

View File

@@ -22,8 +22,7 @@
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"BTCPAY_CHAINS": "btc,ltc", "BTCPAY_CHAINS": "btc,ltc",
"BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver", "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver",
"BTCPAY_INTERNALLIGHTNINGNODE": "http://api-token:foiewnccewuify@127.0.0.1:54938/", "BTCPAY_INTERNALLIGHTNINGNODE": "http://api-token:foiewnccewuify@127.0.0.1:54938/"
"BTCPAY_BUNDLEJSCSS": "true"
}, },
"applicationUrl": "http://localhost:14142/" "applicationUrl": "http://localhost:14142/"
} }