My project structure looks like this
root/
lib/
js/
In my js folder I have a require-config file which references javascript-files in the lib directory. Like so:
require.config({
paths: {
jquery: ["../lib/jquery/dist/jquery"],
}
});
Initiated in view like so:
<script data-main="js/require-config" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.1/require.min.js"></script>
<script>require(["viewModels/searchViewModel"]);</script>
And this is how my searchViewModel looks like (omitted code inside function), generated from typescript:
define(["require", "exports", "jquery"], function (require, exports, $) {
"use strict";
var SearchViewModel = (function () {
function SearchViewModel() {
}
return SearchViewModel;
}
});
For most of the time, there seems to be no problem finding the correct file. Occasionally though, it is looking for the jquery file in /js/jquery.js which will cause the browser to throw a 404 for http://localhost/js/jquery.js.
Am I doing something wrong in the require config? And how come it works sometimes and sometimes not?