コード例 #1
0
        public static void ConfigureWebpack(this HttpApplication application, IPathMappingService pathMappingService, params WebpackConfig[] configurations)
        {
            if (application == null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            new HttpApplicationStateWrapper(application.Application)
            .ConfigureWebpack(new Webpack(configurations, pathMappingService));
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Webpack" /> class.
        /// </summary>
        /// <param name="configurations">The webpack configurations.</param>
        /// <param name="httpServerUtility">The HTTP server utility.</param>
        /// <exception cref="System.ArgumentNullException">configs
        /// or
        /// server</exception>
        public Webpack(IEnumerable <WebpackConfig> configurations, IPathMappingService pathMappingService)
        {
            if (configurations == null)
            {
                throw new ArgumentNullException(nameof(configurations));
            }
            if (pathMappingService == null)
            {
                throw new ArgumentNullException(nameof(pathMappingService));
            }

            this.assets = new Lazy <IEnumerable <WebpackAssetsDictionary> >(() => configurations
                                                                            .Select(config => GetAssetDictionaryForConfig(config, pathMappingService))
                                                                            .ToList());
        }
コード例 #3
0
        /// <summary>
        /// Gets the webpack asset dictionary for the specified <paramref name="configuration"/>.
        /// </summary>
        /// <param name="configuration">The webpack configuration.</param>
        /// <param name="httpServerUtility">The HTTP server utility.</param>
        /// <returns>
        /// The webpack asset dictionary.
        /// </returns>
        private static WebpackAssetsDictionary GetAssetDictionaryForConfig(WebpackConfig configuration, IPathMappingService pathMappingService)
        {
            var assets = WebpackAssetsDictionary.FromFile(pathMappingService.MapPath(configuration.AssetManifestPath));

            assets.RootFolder = configuration.AssetOutputPath;

            return(assets);
        }