0

.NET MVC 5 アプリケーションで Web 最適化フレームワークのバンドルおよび縮小機能を使用しています。

BundleConfig.cs:

    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"));

     }

_Layout.cshtmlファイルでは、次のようにバンドルを参照しています。

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

これは、リリース モードの場合、つまりdebug = false、サーバー側とクライアント側の両方で例外なく機能します。

ただし、デバッグを true に設定すると、front.js.

これをイベントに追加しようとしましたApplication_Start()が、まだ同じ問題が発生します:

#if DEBUG
            BundleTable.EnableOptimizations = false;
#else
            BundleTable.EnableOptimizations = true;
#endif

Web.configファイルは次のとおりです。

<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="local@mac.com">
        <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=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>

</configuration>
4

1 に答える 1

1

スクリプト参照を次から変更する必要があります。

"~/Scripts/something.min.js",

に:

"~/Scripts/something.js",

バンドラーが縮小されたファイルを自動的に検索するのはいつですか (規則をdebug使用) 。それ以外の場合は、リストされているファイルが使用されます。falsesomething.min.js

バンドラーは常に縮小されていないファイルを指します。ミニファイヤはこれらを処理できますが、縮小されたコピーを指している場合、縮小を元に戻すことはできません。

于 2016-10-21T20:27:46.803 に答える