Code: Select all
@addTagHelper *, WebOptimizer.Core
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
< /code>
Program.cs:
// Bundling tasks abstracted into static method...
static IAssetPipeline AddBundles(IAssetPipeline pipeline)
{
pipeline.AddJavaScriptBundle("~/bundles/jquery",
"Scripts/jquery-2.1.1.js",
"Scripts/jquery-ui-1.11.4.js",
"Scripts/jquery.unobtrusive-ajax.js",
"Scripts/jquery.ticker.js"
);
return pipeline;
}
// Call to the bundler
services.AddWebOptimizer(pipeline =>
{
AddBundles(pipeline);
}, opt => // I have to explicitly state a default opt...otherwise minification does not work.
{
});
app.UseWebOptimizer();
app.UseStaticFiles();
< /code>
_layout.cshtml (auf alle Ansichten verwiesen): < /p>
< /code>
Probleme < /strong> < /p>
[list]
[*] Die Skripte befinden sich nicht mehr in einem Bundle (z. B. /bündel /jQuery), werden jedoch direkt referenziert. Hier ist die Ausgabe von Firefox Developer Tools: < /li>
< /ol>
GET https://localhost:7063/Scripts/jquery-2.1.1.js?v=CPMzgO5SHQa9XMvzKiSCYj6ECb0Edy0rHFl04JXlkY0
GET https://localhost:7063/Scripts/jquery-ui-1.11.4.js?v=R9bDu_ZQj9QsBSatxVF1s40Ckf5e7NJDAg-CYP1ZcZM
< /code>
Das Framework scheint nach den Skripten im aktuellen Verzeichnis zu suchen. Wenn ich beispielsweise zu https: // localhost: 7063/account navigiere, passiert Folgendes:
[/list]
GET https://localhost:7063/Account/Scripts/jquery-2.1.1.js?v=CPMzgO5SHQa9XMvzKiSCYj6ECb0Edy0rHFl04JXlkY0
GET https://localhost:7063/Account/Scripts/jquery-ui-1.11.4.js?v=R9bDu_ZQj9QsBSatxVF1s40Ckf5e7NJDAg-CYP1ZcZM