public WebPackMiddlewareOptions Execute(string configFile, string outputFileName, WebpackDevServerOptions devServerOptions) { var enableHotLoading = devServerOptions != null; var toolToExecute = enableHotLoading ? webpackDevServer : webpack; var logger = _loggerFactory.CreateLogger(toolToExecute); logger.LogInformation($"Verifying required tools are installed"); EnsuereNodeModluesInstalled(enableHotLoading, logger); logger.LogInformation($"All node modules are properly installed"); logger.LogInformation($"{toolToExecute} Execution started"); var arguments = $"--config {configFile}"; logger.LogInformation($"{toolToExecute} is called with these arguments: {arguments}"); Process process = new Process(); process.StartInfo = new ProcessStartInfo() { FileName = GetNodeExecutable(toolToExecute), Arguments = arguments, UseShellExecute = false }; process.Start(); logger.LogInformation($"{toolToExecute} started successfully"); var middleWareOptions = new WebPackMiddlewareOptions { OutputFileName = outputFileName, EnableHotLoading = enableHotLoading }; if (enableHotLoading) { middleWareOptions.Host = devServerOptions.Host; middleWareOptions.Port = devServerOptions.Port; } return middleWareOptions; }
public WebPackMiddlewareOptions Execute(string configFile, string outputFileName, WebpackDevServerOptions devServerOptions) { var enableHotLoading = devServerOptions != null; var toolToExecute = enableHotLoading ? WEBPACK_DEV_SERVER : WEBPACK; var logger = _loggerFactory.CreateLogger(toolToExecute); logger.LogInformation($"Verifying required tools are installed"); EnsuereNodeModluesInstalled(enableHotLoading, logger); logger.LogInformation($"All node modules are properly installed"); logger.LogInformation($"{toolToExecute} Execution started"); var arguments = $"--config {configFile}"; logger.LogInformation($"{toolToExecute} is called with these arguments: {arguments}"); new Process { StartInfo = new ProcessStartInfo { FileName = GetWebpackToolToExeceute(toolToExecute), Arguments = arguments, UseShellExecute = false } }.Start(); logger.LogInformation($"{toolToExecute} started successfully"); var middleWareOptions = new WebPackMiddlewareOptions { OutputFileNames = new List <string> { outputFileName }, EnableHotLoading = enableHotLoading }; if (!enableHotLoading) { return(middleWareOptions); } middleWareOptions.Host = devServerOptions.Host; middleWareOptions.Port = devServerOptions.Port; return(middleWareOptions); }
public WebpackMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, WebPackMiddlewareOptions options) { _next = next; _logger = loggerFactory.CreateLogger<WebpackMiddleware>(); _options = options; }
public WebpackMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, WebPackMiddlewareOptions options) { _next = next; _logger = loggerFactory.CreateLogger <WebpackMiddleware>(); _options = options; }