Пример #1
0
        public async Task <IWebpackFile> GetFile(string filename)
        {
            if (_host == null)
            {
                throw new Exception("WebpackService has not been started");
            }

            var absolutePath = Path.Combine(_environment.ContentRootPath, _options.WebRoot, filename.Substring(1));
            var webpackFile  = await _host.Invoke <WebpackFile>("getFile", absolutePath);

            return(webpackFile);
        }
Пример #2
0
        public async Task Start(CancellationToken stoppingToken)
        {
            var environmentVariables = new Dictionary <string, string>();

            environmentVariables["NODE_ENV"] = _environment.EnvironmentName.ToLower();

            var startParams = new {
                LogLevel = _options.LogLevel,
                EnvParam = _options.EnvParam ?? _environment.EnvironmentName.ToLower()
            };

            _host = await NodeHost.Create("webpack-aspnet-middleware", _environment.ContentRootPath, stoppingToken, _logger, environmentVariables);

            _host.Emit += WebpackEmit;

            await _host.Invoke("start", Path.Combine(_environment.ContentRootPath, _options.ConfigFile), startParams.LogLevel);
        }