Exemple #1
0
        protected AbpTagHelperResourceService(
            IBundleManager bundleManager,
            IWebContentFileProvider webContentFileProvider,
            IOptions <BundlingOptions> options,
            IWebHostEnvironment hostingEnvironment)
        {
            BundleManager          = bundleManager;
            WebContentFileProvider = webContentFileProvider;
            HostingEnvironment     = hostingEnvironment;
            Options = options.Value;

            Logger = NullLogger <AbpTagHelperResourceService> .Instance;
        }
        /// <summary>
        /// Registers all the Rock bundles.
        /// </summary>
        /// <param name="app">The application.</param>
        public static void UseRockBundles(this IApplicationBuilder app)
        {
            var bundlingOptions = new BundlingOptions
            {
                RequestPath = "/Scripts/Bundles"
            };

            app.UseBundling(bundlingOptions, bundles =>
            {
                bundles.AddJs("/RockJQueryLatest.js")
                .Include("/Scripts/jquery-3.3.1.js")
                .Include("/Scripts/jquery-migrate-3.0.0.min.js");

                bundles.AddJs("/RockLibs.js")
                .Include("/Scripts/jquery-ui-1.10.4.custom.min.js")
                .Include("/Scripts/bootstrap.min.js")
                //.Include( "/Scripts/bootstrap-timepicker.js" )
                //.Include( "/Scripts/bootstrap-datepicker.js" )
                .Include("/Scripts/bootstrap-limit.js")
                .Include("/Scripts/bootstrap-modalmanager.js")
                .Include("/Scripts/bootstrap-modal.js")
                .Include("/Scripts/bootbox.min.js")
                .Include("/Scripts/chosen.jquery.min.js")
                .Include("/Scripts/typeahead.min.js")
                //.Include( "/Scripts/jquery.fileupload.js" )
                .Include("/Scripts/jquery.stickytableheaders.js")
                //.Include( "/Scripts/iscroll.js" )
                .Include("/Scripts/jcrop.min.js")
                .Include("/Scripts/ResizeSensor.js")
                //.Include( "/Scripts/ion.rangeSlider/js/ion-rangeSlider/ion.rangeSlider.min.js" )
                .Include("/Scripts/Rock/Extensions/*.js");

                bundles.AddJs("/RockUi.js")
                .Include("/Scripts/Rock/coreListeners.js")
                .Include("/Scripts/Rock/dialogs.js")
                .Include("/Scripts/Rock/settings.js")
                .Include("/Scripts/Rock/utility.js")
                .Include("/Scripts/Rock/Controls/*.js")
                .Exclude("/Scripts/Rock/Controls/bootstrap-colorpicker.min.js")
                .Include("/Scripts/Rock/reportingInclude.js");

                bundles.AddJs("/RockValidation.js")
                .Include("/Scripts/Rock/Validate/*.js");

                // Creating a separate "Admin" bundle specifically for JS functionality that needs
                // to be included for administrative users
                bundles.AddJs("/RockAdmin.js")
                .Include("/Scripts/Rock/Admin/*.js");
            });
        }
        private BundleEnvironmentOptions ConfigureBundleEnvironmentOptions(BundlingOptions bundleOptions)
        {
            var bundleEnvironmentOptions = new BundleEnvironmentOptions();

            // auto-invalidate bundle if files change in debug
            bundleEnvironmentOptions.DebugOptions.FileWatchOptions.Enabled = true;
            // set cache busters
            bundleEnvironmentOptions.DebugOptions.SetCacheBusterType(_cacheBusterType);
            bundleEnvironmentOptions.ProductionOptions.SetCacheBusterType(_cacheBusterType);
            // config if the files should be combined
            bundleEnvironmentOptions.ProductionOptions.ProcessAsCompositeFile = bundleOptions.EnabledCompositeFiles;

            return(bundleEnvironmentOptions);
        }
    // only issue with creating bundles like this is that we don't have full control over the bundle options, though that could
    public void CreateCssBundle(string bundleName, BundlingOptions bundleOptions, params string[]?filePaths)
    {
        if (filePaths?.Any(f => !f.StartsWith("/") && !f.StartsWith("~/")) ?? false)
        {
            throw new InvalidOperationException("All file paths must be absolute");
        }

        if (_bundles.Exists(bundleName))
        {
            throw new InvalidOperationException($"The bundle name {bundleName} already exists");
        }

        PreProcessPipeline pipeline = bundleOptions.OptimizeOutput
            ? _cssOptimizedPipeline.Value
            : _cssNonOptimizedPipeline.Value;

        Bundle bundle = _bundles.Create(bundleName, pipeline, WebFileType.Css, filePaths);

        bundle.WithEnvironmentOptions(ConfigureBundleEnvironmentOptions(bundleOptions));
    }
        public static IApplicationBuilder UseBundling(this IApplicationBuilder @this, BundlingOptions options, Action <BundleCollectionConfigurer> configureBundles = null)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (HttpContextStatic.Current == null)
            {
                HttpContextStatic.Initialize(@this.ApplicationServices.GetRequiredService <IHttpContextAccessor>());
            }

            var sourceFileProvider =
                options.SourceFileProvider ??
                @this.ApplicationServices.GetRequiredService <IHostingEnvironment>().WebRootFileProvider;

            var bundles = new BundleCollection(options.RequestPath, sourceFileProvider);

            configureBundles?.Invoke(new BundleCollectionConfigurer(bundles, @this.ApplicationServices));

            @this.UseMiddleware <BundlingMiddleware>(bundles, Options.Create(options));

            return(@this);
        }
        public static IApplicationBuilder UseBundling(this IApplicationBuilder builder, BundlingOptions options, BundlingConfiguration configuration)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(builder.UseBundling(new BundlingOptions(options, configuration), configuration.Configure));
        }
        public static IApplicationBuilder UseBundling(this IApplicationBuilder builder, BundlingOptions options, Action <BundleCollectionConfigurer> configureBundles = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (HttpContextStatic.Current == null)
            {
                HttpContextStatic.Initialize(builder.ApplicationServices.GetRequiredService <IHttpContextAccessor>());
            }

            IFileProvider sourceFileProvider = options.SourceFileProvider ?? builder.ApplicationServices.GetRequiredService <IHostingEnvironment>().WebRootFileProvider;

            var bundles = new BundleCollection(
                options.RequestPath,
                sourceFileProvider,
                options.CaseSensitiveSourceFilePaths ?? AbstractionFile.GetDefaultCaseSensitiveFilePaths(sourceFileProvider));

            configureBundles?.Invoke(new BundleCollectionConfigurer(bundles, builder.ApplicationServices));

            builder.UseMiddleware <BundlingMiddleware>(bundles, Options.Create(options));

            return(builder);
        }