public ResourceBundleProvider(IWebHostEnvironment hosting, BundleOptions options) { if (options.UseBundles) { _BundlesByName = new Lazy <Dictionary <string, Bundle> >(() => { using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BTCPayServer.bundleconfig.json"); using var reader = new StreamReader(stream, Encoding.UTF8); var content = reader.ReadToEnd(); return(JArray.Parse(content).OfType <JObject>() .Select(jobj => new Bundle() { Name = jobj.Property("name", StringComparison.OrdinalIgnoreCase)?.Value.Value <string>() ?? jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value <string>(), OutputFileUrl = Path.Combine(hosting.ContentRootPath, jobj.Property("outputFileName", StringComparison.OrdinalIgnoreCase).Value.Value <string>()) }).ToDictionary(o => o.Name, o => o)); }, true); } else { _InnerProvider = new BundleProvider(hosting); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); var configuration = new DefaultBundleConfigurationBuilder() .SetupBundling(new BundlingSettings { AutoRefresh = true, CombineResponse = true, FallbackOnError = true, IncludeContentHash = true }) .SetupCaching(new CachingSettings { Enabled = true, UseEtag = true }) .SetupCompression(new CompressSettings { CompressionAlgorithm = CompressionAlgorithm.All }) .SetupLess(new LessSettings { Compress = true, Debug = true }) .SetupJavaScript(new JavaScriptSettings { Minify = true }) .Create(); // Setup BundleProvider var bundleContext = new AspNetBundleContext(configuration, new DebugBundleDiagnostic()); var bundleProvider = new BundleProvider(bundleContext); // Init initial bundles BundleConfig.SetupBundler(bundleProvider); // Initialize Bundling engine AspNetBundler.Initialize(bundleProvider); }