Пример #1
0
        public static JsBundleConfigurer EnableEs6ModuleBundling(this JsBundleConfigurer configurer, Action <ModuleBundlerOptions> configure = null)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }

            configurer.Bundle.Transforms = configurer.Bundle.Transforms.Modify(
                l =>
            {
                l.RemoveAll(t => t is ModuleBundlingTransform);

                var index = l.FindIndex(t => t is JsMinifyTransform);
                if (index < 0)
                {
                    index = l.Count;
                }

                IModuleBundlerFactory moduleBundlerFactory = configurer.AppServices.GetRequiredService <IModuleBundlerFactory>();

                var options = new ModuleBundlerOptions
                {
                    DevelopmentMode = configurer.AppServices.GetService <IHostingEnvironment>()?.IsDevelopment() ?? false
                };

                configure?.Invoke(options);

                l.Insert(index, new ModuleBundlingTransform(moduleBundlerFactory, options));
            });

            return(configurer);
        }
Пример #2
0
        public ModuleBundlingTransform(IModuleBundlerFactory moduleBundlerFactory, ModuleBundlerOptions options)
        {
            if (moduleBundlerFactory == null)
            {
                throw new ArgumentNullException(nameof(moduleBundlerFactory));
            }

            _moduleBundlerFactory = moduleBundlerFactory;
            _options = options;
        }