Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have multiple require.js projects included in one html file?

I would like to do something like this:

<script data-main="/js/D4/build/mainD4" src="/js/D4/build/require.js"></script>
<script data-main="/js/main" src="/js/require.js"></script>

I could just build the first file, and the include the build js file in /js/main, but it would be much faster to be able to do development on both projects side by side without having to build all of the time. Right now when I try this, mainD4 builds and then nothing happens with the js/main file.

like image 680
Jeremy Smith Avatar asked May 08 '12 16:05

Jeremy Smith


1 Answers

Just found the answer here: https://groups.google.com/forum/?fromgroups#!topic/requirejs/YWFdgYSU2f4

<script src="scripts/require.js" data-main="scripts/main"></script>
<script>
require(['scripts/another/main']);
</script>

or

<script src="scripts/require.js" data-main="scripts/main"></script>
<script>
(function(){
  var req = require.config({baseUrl:'scripts/another'});
  req(['main']);
}());
</script>
like image 141
Jeremy Smith Avatar answered Oct 06 '22 01:10

Jeremy Smith