Is it possible to stop requireJS from adding the .js file extension automatically?
Solution 1:
If you don't feel like adding a dependency on noext, you can also just append a dummy query string to the path to prevent the .js extension from being appended, as in:
require.config({
paths: {
'signalr-hubs': '/signalr/hubs?noext'
}
});
This is what the noext plugin does.
Solution 2:
requirejs' noext plugin:
Load scripts without appending ".js" extension, useful for dynamic scripts...
Documentation
check the
examples
folder. All the info you probably need will be inside comments or on the example code itself.Basic usage
Put the plugins inside the
baseUrl
folder (usually same folder as the main.js file) or create an alias to the plugin location:require.config({ paths : { //create alias to plugins (not needed if plugins are on the baseUrl) async: 'lib/require/async', font: 'lib/require/font', goog: 'lib/require/goog', image: 'lib/require/image', json: 'lib/require/json', noext: 'lib/require/noext', mdown: 'lib/require/mdown', propertyParser : 'lib/require/propertyParser', markdownConverter : 'lib/Markdown.Converter' } }); //use plugins as if they were at baseUrl define([ 'image!awsum.jpg', 'json!data/foo.json', 'noext!js/bar.php', 'mdown!data/lorem_ipsum.md', 'async!http://maps.google.com/maps/api/js?sensor=false', 'goog!visualization,1,packages:[corechart,geochart]', 'goog!search,1', 'font!google,families:[Tangerine,Cantarell]' ], function(awsum, foo, bar, loremIpsum){ //all dependencies are loaded (including gmaps and other google apis) } );