public override List<Bundle> ParseConfigs() { if (!Directory.Exists(ProjectPath)) { throw new DirectoryNotFoundException("Could not find project directory."); } FindConfigs(); var loader = new ConfigLoader( FilePaths, new ExceptionThrowingLogger(), new ConfigLoaderOptions { ProcessBundles = true }); Configuration = loader.Get(); var bundles = new List<Bundle>(); foreach (var bundleDefinition in Configuration.Bundles.BundleEntries.Where(r => !r.IsVirtual)) { var bundle = new Bundle(); bundle.Output = GetOutputPath(bundleDefinition.OutputPath, bundleDefinition.Name); bundle.Files = bundleDefinition.BundleItems .Select(r => new FileSpec(this.ResolvePhysicalPath(r.RelativePath), r.CompressionType)) .ToList(); bundles.Add(bundle); } return bundles; }
public override List<Bundle> ParseConfigs() { if (!Directory.Exists(ProjectPath)) { throw new DirectoryNotFoundException("Could not find project directory."); } FindConfigs(); var loader = new ConfigLoader( FilePaths, new ExceptionThrowingLogger(), new ConfigLoaderOptions { ProcessBundles = true }); Configuration = loader.Get(); var bundles = Configuration.AutoBundles.Bundles .Select(autoBundle => createBundleOf(autoBundle)) .ToList(); this.WriteOverrideConfigs(bundles); return bundles; }
public override List<Bundle> ParseConfigs() { var bundles = new List<Bundle>(); if (!Directory.Exists(ProjectPath)) { throw new DirectoryNotFoundException("Could not find project directory."); } FindConfigs(); var loader = new ConfigLoader( FilePaths, new ExceptionThrowingLogger(), new ConfigLoaderOptions { ProcessBundles = true }); Configuration = loader.Get(); foreach (var bundle in Configuration.AutoBundles.Bundles) { var files = new List<string>(); var bundleResult = new Bundle { Files = new List<FileSpec>(), Output = this.GetOutputPath(bundle.OutputPath, bundle.Id), ContainingConfig = bundle.ContainingConfig, BundleId = bundle.Id }; bundles.Add(bundleResult); var tempFileList = new List<RequireFile>(); foreach (var include in bundle.Includes) { // check if the file path is actually an URL if (!string.IsNullOrEmpty(include.File) && !include.File.Contains("?")) { files.Add(this.ResolvePhysicalPath(include.File)); } else if(!string.IsNullOrEmpty(include.Directory)) { var absDirectory = this.GetAbsoluteDirectory(include.Directory); // not using filter for this since we're going to use the one the user provided in the future var dirFiles = Directory.GetFiles(absDirectory, "*", SearchOption.AllDirectories).Where(r => Path.GetExtension(r) == ".js").ToList(); files.AddRange(dirFiles); } } files = files.Distinct().ToList(); var fileQueue = new Queue<string>(); this.EnqueueFileList(tempFileList, fileQueue, files); while (fileQueue.Any()) { var file = fileQueue.Dequeue(); var fileText = File.ReadAllText(file, encoding); var relativePath = PathHelpers.GetRelativePath(file, EntryPoint + Path.DirectorySeparatorChar); var processor = new ScriptProcessor(relativePath, fileText, Configuration); processor.Process(); var result = processor.ProcessedString; var dependencies = processor.Dependencies.Select(r => this.ResolvePhysicalPath(r)).Where(r => r != null).Distinct().ToList(); tempFileList.Add(new RequireFile { Name = file, Content = result, Dependencies = dependencies }); this.EnqueueFileList(tempFileList, fileQueue, dependencies); } while (tempFileList.Any()) { var addedFiles = bundleResult.Files.Select(r => r.FileName).ToList(); var noDeps = tempFileList.Where(r => !r.Dependencies.Any() || r.Dependencies.All(x => addedFiles.Contains(x))).ToList(); if (!noDeps.Any()) { noDeps = tempFileList.ToList(); } foreach (var requireFile in noDeps) { bundleResult.Files.Add(new FileSpec(requireFile.Name, string.Empty) { FileContent = requireFile.Content }); tempFileList.Remove(requireFile); } } } this.WriteOverrideConfigs(bundles); return bundles; }