protected virtual IFileInfo GetFileInfo(IBundlerContext context, string file) { var fileInfo = WebContentFileProvider.GetFileInfo(file); if (!fileInfo.Exists) { throw new AbpException($"Could not find file '{file}' using {nameof(IWebContentFileProvider)}"); } return(fileInfo); }
protected virtual IFileInfo GetMinFileInfoOrNull(string file) { foreach (var suffix in _minFileSuffixes) { var fileInfo = WebContentFileProvider.GetFileInfo( $"{file.RemovePostFix($".{FileExtension}")}.{suffix}.{FileExtension}" ); if (fileInfo.Exists) { return(fileInfo); } } return(null); }
public virtual async Task ProcessAsync( [NotNull] ViewContext viewContext, [NotNull] TagHelperContext context, [NotNull] TagHelperOutput output, [NotNull] List <BundleTagHelperItem> bundleItems, [CanBeNull] string bundleName = null) { Check.NotNull(viewContext, nameof(viewContext)); Check.NotNull(context, nameof(context)); Check.NotNull(output, nameof(output)); Check.NotNull(bundleItems, nameof(bundleItems)); var stopwatch = Stopwatch.StartNew(); output.TagName = null; if (bundleName.IsNullOrEmpty()) { bundleName = GenerateBundleName(bundleItems); } CreateBundle(bundleName, bundleItems); var bundleFiles = await GetBundleFilesAsync(bundleName); output.Content.Clear(); foreach (var bundleFile in bundleFiles) { var file = WebContentFileProvider.GetFileInfo(bundleFile); if (file == null || !file.Exists) { throw new AbpException($"Could not find the bundle file '{bundleFile}' from {nameof(IWebContentFileProvider)}"); } if (file.Length > 0) { AddHtmlTag(viewContext, context, output, bundleFile + "?_v=" + file.LastModified.UtcTicks); } } stopwatch.Stop(); Logger.LogDebug($"Added bundle '{bundleName}' to the page in {stopwatch.Elapsed.TotalMilliseconds:0.00} ms."); }
protected virtual IFileInfo GetMinFileInfoOrNull(string file) { var fileInfo = WebContentFileProvider.GetFileInfo($"{file.RemovePostFix($".{FileExtension}")}.min.{FileExtension}"); return(fileInfo.Exists ? fileInfo : null); }