ASP.NET MVC4 Bundle a single file

前端 未结 3 1280
南方客
南方客 2021-02-14 18:57

Is there a way to bundle a single file using the new bundling features in MVC4? I know bundling a single file doesn\'t make much sense but I\'d like to use server-side minificat

3条回答
  •  孤街浪徒
    2021-02-14 19:45

    Well, define a bundle containing only this file in your bundle config:

    bundles.Add(
        new ScriptBundle("~/bundles/myscript").Include("~/Scripts/myscript.js")
    );
    

    and then use it in your view by referencing it by name:

    @Scripts.Render("~/bundles/myscript")
    

提交回复
热议问题