public AssetCombinationBuildingActivator(IContainerFacility container, AssetGraph graph, IAssetCombinationCache cache, IAssetPipeline pipeline)
 {
     _container = container;
     _graph = graph;
     _cache = cache;
     _pipeline = pipeline;
 }
Exemple #2
0
 public AssetCombinationBuildingActivator(IContainerFacility container, AssetGraph graph, IAssetCombinationCache cache, IAssetPipeline pipeline)
 {
     _container = container;
     _graph     = graph;
     _cache     = cache;
     _pipeline  = pipeline;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseTagHelper"/> class.
 /// </summary>
 public BaseTagHelper(IHostingEnvironment env, IMemoryCache cache, IAssetPipeline pipeline, IOptionsSnapshot <WebOptimizerOptions> options)
 {
     HostingEnvironment = env;
     Cache    = cache;
     Pipeline = pipeline;
     Options  = options.Value;
 }
Exemple #4
0
        internal static IAsset CreateCssAsset(IAssetPipeline pipeline, string key)
        {
            var route = string.Concat("/css/", key, ".css");
            var asset = AddBundleByKey(pipeline, route, "text/css; charset=UTF-8");

            var settings = ServiceExtensions.CssBundlingSettings;

            if (settings.EnforceFileExtensions?.Length > 0)
            {
                asset = asset.EnforceFileExtensions(settings.EnforceFileExtensions);
            }

            if (settings.AdjustRelativePaths)
            {
                asset = asset.AdjustRelativePaths();
            }

            if (settings.Concatenate)
            {
                asset.Processors.Add(Concatenator);
            }

            if (settings.FingerprintUrls)
            {
                asset = asset.FingerprintUrls();
            }

            if (settings.Minify)
            {
                asset = asset.MinifyCss(settings.CssSettings);
            }

            return(asset);
        }
 /// <summary>
 /// Creates a JavaScript bundle on the specified route and minifies the output.
 /// </summary>
 public static IAsset AddJavaScriptBundle(this IAssetPipeline pipeline, string route, CodeSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "application/javascript; charset=UTF-8", sourceFiles)
            .EnforceFileExtensions(".js", ".jsx", ".es5", ".es6")
            .Concatenate()
            .MinifyJavaScript(settings));
 }
Exemple #6
0
 /// <summary>
 /// Minifies the specified .css files.
 /// </summary>
 public static IEnumerable <IAsset> MinifyCssFiles(this IAssetPipeline pipeline, CssSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddFiles("text/css; charset=UTF-8", sourceFiles)
            .FingerprintUrls()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyCss(settings));
 }
 /// <summary>
 /// Compiles .scss files into CSS and makes them servable in the browser.
 /// </summary>
 /// <param name="pipeline">The asset pipeline.</param>
 public static IEnumerable <IAsset> CompileScssFiles(this IAssetPipeline pipeline)
 {
     return(pipeline.AddFiles("text/css; charset=UTF-8", "**/*.scss")
            .CompileScss()
            .FingerprintUrls()
            .MinifyCss());
 }
 /// <summary>
 /// Compiles the specified .scss files into CSS and makes them servable in the browser.
 /// </summary>
 /// <param name="pipeline">The pipeline object.</param>
 /// <param name="sourceFiles">A list of relative file names of the sources to compile.</param>
 public static IEnumerable <IAsset> CompileScssFiles(this IAssetPipeline pipeline, params string[] sourceFiles)
 {
     return(pipeline.AddFiles("text/css; charset=UFT-8", sourceFiles)
            .CompileScss()
            .FingerprintUrls()
            .MinifyCss());
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseTagHelper"/> class.
 /// </summary>
 public BaseTagHelper(IWebHostEnvironment env, IMemoryCache cache, IAssetPipeline pipeline, IOptionsMonitor <WebOptimizerOptions> options)
 {
     HostingEnvironment = env;
     Cache    = cache;
     Pipeline = pipeline;
     Options  = options.CurrentValue;
 }
Exemple #10
0
        internal static IAsset CreateJsAsset(IAssetPipeline pipeline, string key)
        {
            var route = string.Concat("/js/", key, ".js");
            var asset = AddBundleByKey(pipeline, route, "application/javascript; charset=UTF-8");

            var settings = ServiceExtensions.CodeBundlingSettings;


            if (settings.EnforceFileExtensions?.Length > 0)
            {
                asset = asset.EnforceFileExtensions(settings.EnforceFileExtensions);
            }

            if (settings.AdjustRelativePaths)
            {
                asset = asset.AdjustRelativePaths();
            }

            if (settings.Concatenate)
            {
                asset.Processors.Add(Concatenator);
            }

            if (settings.Minify)
            {
                asset = asset.MinifyJavaScript(settings.CodeSettings);
            }

            return(asset);
        }
        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);
                }
            });
        }
Exemple #12
0
 public ContentPlanner(IAssetCombinationCache combinations, IAssetPipeline pipeline,
                       ITransformerPolicyLibrary library)
 {
     _combinations = combinations;
     _pipeline = pipeline;
     _library = library;
 }
 public AssetMiddleware(RequestDelegate next, IAssetPipeline pipeline, ILogger <AssetMiddleware> logger, IAssetBuilder assetBuilder)
 {
     _next         = next;
     _pipeline     = pipeline;
     _logger       = logger;
     _assetBuilder = assetBuilder;
 }
 public ContentPlanner(IAssetCombinationCache combinations, IAssetPipeline pipeline,
     ITransformerPolicyLibrary library)
 {
     _combinations = combinations;
     _pipeline = pipeline;
     _library = library;
 }
 /// <summary>
 /// Compile markdown files on the asset pipeline.
 /// </summary>
 /// <param name="pipeline">The asset pipeline.</param>
 /// <param name="route">The route where the compiled markdown file will be available from.</param>
 /// <param name="sourceFiles">The path to the markdown source files to compile.</param>
 public static IAsset AddTypeScriptBundle(this IAssetPipeline pipeline, string route, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "application/javascript; charset=UTF-8", sourceFiles)
            .CompileTypeScript()
            .Concatenate()
            .MinifyJavaScript());
 }
Exemple #16
0
 /// <summary>
 /// Creates a HTML bundle on the specified route and minifies the output.
 /// </summary>
 public static IAsset AddHtmlBundle(this IAssetPipeline pipeline, string route, HtmlSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "text/html; charset=UTF-8", sourceFiles)
            .EnforceFileExtensions(".htm", ".html", ".xhtml", ".xhtm", ".shtml", ".shtm", ".js", ".nj", ".njk", ".njs", ".nunj", ".nunjs", ".nunjucks", ".smarty", ".svg", ".tpl", ".vue", ".vash", ".ejs", ".erb", ".liquid", ".lava", "..spark", ".cfm", ".kit", ".brail", ".twig", ".tag")
            .Concatenate()
            .MinifyHtml(settings));
 }
 /// <summary>
 /// Compiles the specified .scss files into CSS and makes them servable in the browser.
 /// </summary>
 /// <param name="pipeline">The pipeline object.</param>
 /// <param name="sourceFiles">A list of relative file names of the sources to compile.</param>
 public static IEnumerable <IAsset> CompileScssFiles(this IAssetPipeline pipeline, WebOptimazerScssOptions options = null, params string[] sourceFiles)
 {
     return(pipeline.AddFiles("text/css; charset=UFT-8", sourceFiles)
            .CompileScss(options)
            .FingerprintUrls()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyCss());
 }
Exemple #18
0
 /// <summary>
 /// Compiles the specified .less files into CSS and makes them servable in the browser.
 /// </summary>
 /// <param name="pipeline">The pipeline object.</param>
 /// <param name="sourceFiles">A list of relative file names of the sources to compile.</param>
 public static IEnumerable <IAsset> CompileLessFiles(this IAssetPipeline pipeline, params string[] sourceFiles)
 {
     return(pipeline.AddFiles("text/css; charset=UFT-8", sourceFiles).EnforceFileExtensions(".less")
            .CompileLess()
            .FingerprintUrls()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyCss());
 }
Exemple #19
0
 /// <summary>
 /// Compiles .scss files into CSS and makes them servable in the browser.
 /// </summary>
 /// <param name="pipeline">The asset pipeline.</param>
 public static IEnumerable <IAsset> CompileScssFiles(this IAssetPipeline pipeline)
 {
     return(pipeline.AddFiles("text/css; charset=UTF-8", "**/*.scss")
            .CompileScss()
            //    .FingerprintUrls()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyCss());
 }
 public ContentWriter(IAssetPipeline pipeline, IContentPlanCache cache, IContentPipeline contentPipeline,
     IOutputWriter writer)
 {
     _pipeline = pipeline;
     _cache = cache;
     _contentPipeline = contentPipeline;
     _writer = writer;
 }
Exemple #21
0
 public ContentWriter(IAssetPipeline pipeline, IContentPlanCache cache, IContentPipeline contentPipeline,
                      IOutputWriter writer)
 {
     _pipeline        = pipeline;
     _cache           = cache;
     _contentPipeline = contentPipeline;
     _writer          = writer;
 }
Exemple #22
0
 /// <summary>
 /// Creates a JavaScript bundle on the specified route and minifies the output.
 /// </summary>
 public static IAsset AddJavaScriptBundle(this IAssetPipeline pipeline, string route, CodeSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "text/javascript; charset=UTF-8", sourceFiles)
            .EnforceFileExtensions(".js", ".jsx", ".es5", ".es6")
            .Concatenate()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyJavaScript(settings));
 }
Exemple #23
0
        private static IAsset AddBundleByKey(IAssetPipeline pipeline, string route,
                                             string contentType)
        {
            var asset = (Asset)pipeline.AddBundle(route, contentType, EmptySourceFiles);

            asset.SourceFiles = new HashSet <string>();
            return(asset);
        }
 /// <summary>
 /// Compile Sass or Scss files on the asset pipeline.
 /// </summary>
 /// <param name="pipeline">The asset pipeline.</param>
 /// <param name="route">The route where the compiled .css file will be available from.</param>
 /// <param name="sourceFiles">The path to the .sass or .scss source files to compile.</param>
 public static IAsset AddScssBundle(this IAssetPipeline pipeline, string route, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "text/css; charset=UTF-8", sourceFiles)
            .CompileScss()
            .AdjustRelativePaths()
            .Concatenate()
            .FingerprintUrls()
            .MinifyCss());
 }
Exemple #25
0
 /// <summary>
 /// Creates a CSS bundle on the specified route and minifies the output.
 /// </summary>
 public static IAsset AddCssBundle(this IAssetPipeline pipeline, string route, CssSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "text/css; charset=UTF-8", sourceFiles)
            .EnforceFileExtensions(".css")
            .AdjustRelativePaths()
            .Concatenate()
            .FingerprintUrls()
            .MinifyCss(settings));
 }
Exemple #26
0
 /// <summary>
 /// Compile Sass or Scss files on the asset pipeline.
 /// </summary>
 /// <param name="pipeline">The asset pipeline.</param>
 /// <param name="route">The route where the compiled .css file will be available from.</param>
 /// <param name="sourceFiles">The path to the .sass or .scss source files to compile.</param>
 public static IAsset AddScssBundle(this IAssetPipeline pipeline, string route, params string[] sourceFiles)
 {
     return(pipeline.AddBundle(route, "text/css; charset=UTF-8", sourceFiles)
            .CompileScss()
            .AdjustRelativePaths()
            .Concatenate()
            //    .FingerprintUrls()
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyCss());
 }
        /// <summary>
        ///  Creates AngularJs bundle from HTML templates.
        /// </summary>
        /// <param name="pipeline">The asset pipeline.</param>
        /// <param name="route">The route where the compiled .html file will be available from.</param>
        /// <param name="moduleSettings"></param>
        /// <param name="sourceFiles">The path to the .html source files to compile.</param>
        public static IAsset AddHtmlTemplateBundle(this IAssetPipeline pipeline, string route,
                                                   AngularTemplateOptions moduleSettings,
                                                   params string[] sourceFiles)
        {
            Guard.ArgumentIsNotNull(moduleSettings, "Can't be null");

            return(pipeline.AddBundle(route, "text/javascript; charset=UTF-8", sourceFiles)
                   .AdjustRelativePaths()
                   .TransformHtml(moduleSettings));
        }
Exemple #28
0
 public NopLinkTagHelper(AppSettings appSettings,
                         HtmlEncoder htmlEncoder,
                         IAssetPipeline assetPipeline,
                         INopHtmlHelper nopHtmlHelper,
                         IUrlHelperFactory urlHelperFactory) : base(urlHelperFactory, htmlEncoder)
 {
     _appSettings   = appSettings;
     _assetPipeline = assetPipeline ?? throw new ArgumentNullException(nameof(assetPipeline));
     _nopHtmlHelper = nopHtmlHelper;
 }
 protected override void beforeEach()
 {
     _assetGraph    = MockFor <AssetGraph>();
     _precompiler   = MockFor <IAssetPrecompiler>();
     _assetPipeline = MockFor <IAssetPipeline>();
     _precompiler
     .Expect(x => x.Precompile(Arg <IAssetPipeline> .Is.Same(_assetPipeline), Arg <IAssetRegistration> .Is.Same(_assetGraph)))
     .Callback <IAssetPipeline, IAssetRegistration>((x, y) => _result = true);
     _log = MockFor <IPackageLog>();
     Services.Inject <IEnumerable <IAssetPrecompiler> >(new[] { _precompiler });
 }
 public NopScriptTagHelper(AppSettings appSettings,
                           HtmlEncoder htmlEncoder,
                           IAssetPipeline assetPipeline,
                           INopHtmlHelper nopHtmlHelper,
                           IUrlHelperFactory urlHelperFactory,
                           IWebHostEnvironment webHostEnvironment) : base(urlHelperFactory, htmlEncoder)
 {
     _appSettings        = appSettings;
     _assetPipeline      = assetPipeline ?? throw new ArgumentNullException(nameof(assetPipeline));
     _nopHtmlHelper      = nopHtmlHelper;
     _webHostEnvironment = webHostEnvironment;
 }
Exemple #31
0
        private static AssetItem GetOrCreateAssetByKey(IAssetPipeline pipeline, string key,
                                                       Func <IAssetPipeline, string, IAsset> createAsset)
        {
            AssetItem assetItem;

            if (AssetCache.TryGetValue(key, out assetItem) == false)
            {
                lock (AssetCache)
                {
                    assetItem = AssetCache.GetOrAdd(key, new AssetItem
                    {
                        Asset = createAsset(pipeline, key)
                    });
                }
            }

            return(assetItem);
        }
 public BasicAssetDiagnostics(IAssetCombinationCache cache, IContentPlanCache contentPlanCache, IAssetPipeline pipeline)
 {
     _cache = cache;
     _contentPlanCache = contentPlanCache;
     _pipeline = pipeline;
 }
 public AssetPolicyActivator(IEnumerable<IAssetPolicy> policies, IAssetPipeline pipeline, AssetGraph graph)
 {
     _policies = policies;
     _pipeline = pipeline;
     _graph = graph;
 }
Exemple #34
0
 public AssetFileWatcher(IAssetPipeline pipeline, IAssetFileChangeListener listener, AssetFileMonitoringSettings settings)
 {
     _pipeline = pipeline;
     _listener = listener;
     _settings = settings;
 }
 public AssetRequirements(IAssetDependencyFinder finder, IAssetPipeline pipeline)
 {
     _finder = finder;
     _pipeline = pipeline;
 }
Exemple #36
0
 /// <summary>
 /// Minifies tje specified .js files.
 /// </summary>
 public static IEnumerable <IAsset> MinifyJsFiles(this IAssetPipeline pipeline, CodeSettings settings, params string[] sourceFiles)
 {
     return(pipeline.AddFiles("text/javascript; charset=UTF-8", sourceFiles)
            .AddResponseHeader("X-Content-Type-Options", "nosniff")
            .MinifyJavaScript(settings));
 }
 public void Apply(IPackageLog log, IAssetPipeline pipeline, AssetGraph graph)
 {
     graph.ForEachSetName(WarmUpSet);
 }
 public AssetDeclarationChecker(IAssetPipeline pipeline, IPackageLog log, AssetLogsCache assetLogs)
 {
     _pipeline = pipeline;
     _log = log;
     _assetLogs = assetLogs;
 }
 public AssetDeclarationVerificationActivator(IAssetPipeline pipeline, AssetGraph graph, AssetLogsCache assetLogs)
 {
     _pipeline = pipeline;
     _graph = graph;
     _assetLogs = assetLogs;
 }
        public SpecificationGraph(IAssetPipeline pipeline)
        {
            pipeline.AllPackages.Where(IsSpecPackage).Each(AddSpecs);

            _packages.Each(x => x.ApplyHelpers());
        }
 public void Apply(IPackageLog log, IAssetPipeline pipeline, AssetGraph graph)
 {
     // TODO -- make this recording later?
     Replay(graph);
 }
Exemple #42
0
 public AssetTagPlanner(IAssetPipeline pipeline, ICombinationDeterminationService combinations)
 {
     _pipeline = pipeline;
     _combinations = combinations;
 }
 public AssetDeclarationChecker(IAssetPipeline pipeline, IPackageLog log)
 {
     _pipeline = pipeline;
     _log = log;
 }
 public AssetDeclarationVerificationActivator(IAssetPipeline pipeline, AssetGraph graph)
 {
     _pipeline = pipeline;
     _graph = graph;
 }
		public AssetPathResolver(IAssetPipeline assetPipeline) 
		{
			_assetPipeline = assetPipeline;
		}
Exemple #46
0
 /// <summary>
 /// Minifies the specified .js files.
 /// </summary>
 public static IEnumerable <IAsset> MinifyJsFiles(this IAssetPipeline pipeline, params string[] sourceFiles)
 {
     return(pipeline.MinifyJsFiles(new CodeSettings(), sourceFiles));
 }
 public AssetPrecompilerActivator(IEnumerable<IAssetPrecompiler> precompilers, AssetGraph assetGraph, IAssetPipeline assetPipeline)
 {
     _precompilers = precompilers;
     _assetGraph = assetGraph;
     _assetPipeline = assetPipeline;
 }
Exemple #48
0
 /// <summary>
 /// Creates a JavaScript bundle on the specified route and minifies the output.
 /// </summary>
 public static IAsset AddJavaScriptBundle(this IAssetPipeline pipeline, string route, params string[] sourceFiles)
 {
     return(pipeline.AddJavaScriptBundle(route, new CodeSettings(), sourceFiles));
 }
Exemple #49
0
 public ImageWriter(IOutputWriter writer, IAssetPipeline pipeline, IResponseCaching caching)
 {
     _writer = writer;
     _pipeline = pipeline;
     _caching = caching;
 }