.NET MVC 5 응용 프로그램에서 웹 최적화 프레임 워크의 번들 및 축소 기능을 사용하고 있습니다.번들 및 축소 - 스크립트가 디버그 모드에서 참조되지 않습니다.
BundleConfig.cs 다음 _Layout.cshtml
파일에서
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/home").Include(
"~/Scripts/jquery-1.11.0.min.js",
"~/Scripts/bootstrap.min.js",
"~/Scripts/owl.carousel.min.js",
"~/Scripts/wow.min.js",
"~/Scripts/front.js"));
}
이 같은 번들을 참조하고 있습니다 :
@Scripts.Render("~/bundles/home")
이 모두 서버에서 예외없이, 릴리스 모드, 즉 debug = false
에서 작동 & 클라이언트 측.
그러나 디버그를 true로 설정하면 front.js
을 제외한 모든 스크립트가 페이지에서 참조됩니다.
나는 Application_Start()
이벤트에이 추가 시도하지만 난 여전히 같은 문제가 발생 : 당신은에서 스크립트 참조를 변경해야
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="Cache1Week" duration="604800" varyByParam="none"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="localhost" port="25"/>
</smtp>
</mailSettings>
</system.net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
Application_Start()가 아닌 RegisterBundles에 if 논리를 포함하십시오. –
BundleConfig에 넣으려고합니까? 그렇다면 차이는 없습니다. – Esen