title: RequireJS plugin, load files on demand
body: <p>I have RequireJS implemented fine, and a Grunt based build process which is optimizing the all the JS files app into one file via r.js which is also working fine. All my app files are concatenated into one big JS file for efficient production deployment.
  Now I'm having the following requirements:
  I need to write a plugin for requirejs, that will not load(not include the file) into the optimized file in the build process, but will required on demand:
  Meaning in my code I'll have:</p>
  <pre><code>var myObj = require(&quot;myplugIn!jsFile&quot;);
  </code></pre>
  <p>So in the end when this line runs, it will runs in 2 options:</p>
  <ol>
  <li>on build process, the file is not included in the optimized file</li>
  <li>The application is running, it will be request the file on demand.</li>
  </ol>
  <p>I wrote the following plugin, but is not working:</p>
  <pre><code>define(function () {
  &quot;use strict&quot;;
  return {
      load : function (name, req, onload, config) {
          // we go inside here we are running the application not in build process
          if (!config.isBuild) {
              req([name], function () {
                      onload(arguments[0]);
                  });                
          } 
      }
  };
  });
  </code></pre>
  <p>What I'm missing here.</p>