Reputation: 4628
Can I use Require.js in development without using the data-main
attribute to load in my initial script? ie. <script data-main="scripts/main" src="scripts/require.js"></script>
I'm finding it difficult for me to work with this attribute in my development environment.
Upvotes: 33
Views: 19269
Reputation: 1782
Yep, take a look at the documentation: http://requirejs.org/docs/api.html#config
You need to call require.config() and set baseUrl. Based on your example:
<script src="scripts/require.js"></script>
<script>
require.config({
baseUrl: "scripts"
});
require( [ /*...*/ ], function( /*...*/ ) {
/*...*/
});
</script>
Upvotes: 52