squishit の仕組みと同様に、requirejs の最適化をトリガーするための VS 2010 拡張機能があるかどうか疑問に思っていました。
- デバッグ モードでは、モジュール ファイルは個別に保持されます
- リリース モードの場合、モジュール ファイルは縮小および結合されます
squishit の仕組みと同様に、requirejs の最適化をトリガーするための VS 2010 拡張機能があるかどうか疑問に思っていました。
編集:VS2012を使用していますが、一般的な原則は機能するはずです
これはあなたの質問に対する直接的な回答ではありませんが、これは私たちが思いついた回避策です:
最小化してバンドルするファイルのモジュールを作成します。議論のために、それを と呼びますbase_module
。
を作成script
します_layout.cshtml
function requireBaseModulesDebug(func) {
// In debug mode, just execute the call back directly.
// Do not load any base modules, require each module to fully state any dependencies.
func();
}
function requireBaseModulesRelease(func) {
require(["js_modules/base_module"], func);
}
// Views are always in DEBUG mode, so we have to this this work-around.
@if (HttpContext.Current.IsDebuggingEnabled)
{
<text>requireBaseModules = requireBaseModulesDebug;</text>
}
else
{
<text>requireBaseModules = requireBaseModulesRelease;</text>
}
そのスクリプトを作成したら、次のようにモジュールを使用するものをすべてラップする必要があります。
// If you are in DEBUG mode, requireBaseModules won't do anything
// But, if you are in a release mode, then requireBaseModules will load your
// bundled module and have them primed. Any modules required but NOT in your
// base bundle will be loaded normally.
requireBaseModules(function () {
require(['jQuery'], function ($) {
// Do Stuff
});
});