public void Precompile(IAssetPipeline pipeline, IAssetRegistration registration)
        {
            var allFiles = pipeline.AllFiles().Where(x => x.Extension() == ".js");
            allFiles.Each(x =>
            {
                var name = x.LibraryName();
                var content = _fileSystem.ReadStringFromFile(x.FullPath);
                var match = _regex.Match(content);
                if (!match.Success) { return; }

                var tag = match.Groups[1].Value;
                var dependencies = match.Groups[3].Value;
                dependencies = _replacements
                    .Aggregate(dependencies, (current, value) => current.Replace(value, ""));
                var assets = dependencies.Split(',');
                //register all requirejs depedencies into asset graph
                foreach (var asset in assets)
                {
                    registration.Dependency(name, "{0}.js".ToFormat(asset));
                }

                if (tag == "require")
                {
                    _registry.Register(x);
                }
            });
        }
示例#2
0
        public void StartWatchingAll()
        {
            _watcher = new FileChangePollingWatcher();
            _pipeline.AllFiles().Each(file =>
            {
                _watcher.WatchFile(file.FullPath, () => _listener.Changed(file));
            });

            _watcher.StartWatching(_settings.MonitoringIntervalTime);
        }