public void Should_Minify_Simple_Code() { const string source = "var x = 5; var y = 6;"; var minified = _javascriptMinifier.Minify(source); minified.Length.ShouldBeGreaterThan(0); minified.Length.ShouldBeLessThan(source.Length); }
public async Task <ActionResult> Get() { var script = CreateAbpExtendScript(await _configurationAppService.GetAsync()); return(Content( _options.MinifyGeneratedScript == true ? _javascriptMinifier.Minify(script) : script, MimeTypes.Application.Javascript )); }
public ActionResult GetAll(ServiceProxyGenerationModel model) { model.Normalize(); var script = _proxyScriptManager.GetScript(model.CreateOptions()); return(Content( _options.MinifyGeneratedScript == true ? _javascriptMinifier.Minify(script) : script, MimeTypes.Application.Javascript )); }
private string CreateScript(ProxyScriptingModel scriptingModel) { var apiModel = _modelProvider.CreateApiModel(); if (scriptingModel.IsPartialRequest()) { apiModel = apiModel.CreateSubModel(scriptingModel.Modules, scriptingModel.Controllers, scriptingModel.Actions); } var generatorType = _options.Generators.GetOrDefault(scriptingModel.GeneratorType); if (generatorType == null) { throw new AbpException($"Could not find a proxy script generator with given name: {scriptingModel.GeneratorType}"); } using (var scope = _serviceProvider.CreateScope()) { var script = scope.ServiceProvider.GetRequiredService(generatorType).As <IProxyScriptGenerator>().CreateScript(apiModel); return(scriptingModel.Minify ? _javascriptMinifier.Minify(script) : script); } }