目前正在ASP.NET MVC应用程序中工作,探索了角度之后,我对在ASP.NET MVC应用程序中使用Webpack进行捆绑和缩小感到很兴奋。
遵循了webpack指南中的所有步骤,我能够捆绑并缩小js文件。
但是,当我在应用程序中引用该捆绑包时,它比ASP.NET捆绑包花费更多的时间。
下面是ASP.NET捆绑代码
bundles.Add(new ScriptBundle("~/bundles/QuickReasonEntryScripts").Include(
"~/Scripts/jquery.min.js",
"~/Scripts/kendo.all.min.js",
"~/Scripts/bootstrap.js",
"~/Scripts/ComonLibrary.js",
"~/Scripts/Common.js",
"~/Scripts/CommonFunctions.js",
"~/Scripts/QuickReason.Events.js",
"~/Scripts/QuickReason.Ajax.js"
));
Run Code Online (Sandbox Code Playgroud)
在cshtml文件中像下面这样引用
bundles.Add(new ScriptBundle("~/bundles/QuickReasonEntryScripts").Include(
"~/Scripts/jquery.min.js",
"~/Scripts/kendo.all.min.js",
"~/Scripts/bootstrap.js",
"~/Scripts/ComonLibrary.js",
"~/Scripts/Common.js",
"~/Scripts/CommonFunctions.js",
"~/Scripts/QuickReason.Events.js",
"~/Scripts/QuickReason.Ajax.js"
));
Run Code Online (Sandbox Code Playgroud)
以下是请求时间。
Asp.net捆绑脚本仅花费411毫秒,webpack捆绑文件仅花费2.87s
无法理解为什么静态文件需要更多时间。
如何优化呢?我想念什么吗?
谢谢,Badrinarayana