public static JsBundleConfigurer EnableEs6ModuleBundling(this JsBundleConfigurer configurer, Action <ModuleBundlerOptions> configure = null) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } configurer.Bundle.Transforms = configurer.Bundle.Transforms.Modify( l => { l.RemoveAll(t => t is ModuleBundlingTransform); var index = l.FindIndex(t => t is JsMinifyTransform); if (index < 0) { index = l.Count; } IModuleBundlerFactory moduleBundlerFactory = configurer.AppServices.GetRequiredService <IModuleBundlerFactory>(); var options = new ModuleBundlerOptions { DevelopmentMode = configurer.AppServices.GetService <IHostingEnvironment>()?.IsDevelopment() ?? false }; configure?.Invoke(options); l.Insert(index, new ModuleBundlingTransform(moduleBundlerFactory, options)); }); return(configurer); }
public ModuleBundler(ILoggerFactory loggerFactory = null, ModuleBundlerOptions options = null) { _logger = loggerFactory?.CreateLogger <ModuleBundler>() ?? (ILogger)NullLogger.Instance; _br = options?.NewLine ?? Environment.NewLine; _developmentMode = options?.DevelopmentMode ?? false; Modules = new Dictionary <ModuleFile, ModuleData>(); FileProviderPrefixes = new Dictionary <IFileProvider, string>(); }
public IModuleBundler Create(ModuleBundlerOptions options = null) { return(new ModuleBundler(_loggerFactory, options)); }