我想知道是否有任何VS 2010扩展用于触发requirejs优化,类似于squishit的工作方式:
答案 0 :(得分:0)
编辑:我们使用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
});
});