Requirement Optimizer and VS 2010 Itegration

I was wondering if there are any VS 2010 extensions there to run requirejs optimization similar to how squishit works:

  • When in debug mode, the module files remain separate
  • When in release mode, the module files become thumbnails and merged
+5
source share
1 answer

Edit: we are using VS2012, but the general principle should work

Although this is not a direct answer to your question, this is the work we encountered:

Create a module for the files you want to minimize and link. Name it for discussion base_module.

Create scriptin_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>
}

script , :

// 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
    });
});
0

All Articles