How to force require.js to load all resources from one directory

680 Views Asked by At

I have typescript generating a javascript file that starts with this line:

define(["require", "exports", "jquery", "chart.js", "./util"], function (require, exports, $, chart, util_1) {

I want all of those dependencies to be loaded from /static/XXX.js, however require.js fires off the following requests:

/static/initialscript.js (I put the abstract path in data-main)
/static/jquery.js (exactly what I want)
/html/chart.js (uses relative path to HTML file - ERROR)
/html/util (uses relative path to HTML and doesn't append .js - ERROR)

I tried to set the base path in the require.js configuration, however this didn't change anything.

How can I force require.js to load all dependencies from the /static/ folder on my webserver?

Update:

This is the HTML code I use to load the script:

<script data-main="/static/initialscript.js" src="/static/require.js"></script>

I tried the above with both no configuration and a configuration that I created before the above line:

<script>
var require = {
    baseUrl: '/static/',
    paths: {
        'chart.js': '/static/chart.js'
    }
};
</script>
0

There are 0 best solutions below