1
votes

I have migrated our project from 506 to 61. as part of the migration i switched the dojo code to use the new dojo server implementation.

The problem i am having now is that custom js files that i used require(AMD) to load is now failing because its looking to the new dojo server for the js file. Is there a way to dojo to look for my custom js files within the applications js directory instead of the dojolib project?

ex.

require(["js/custom/controllers/categories"], function(cat){
     //do stuff
})

is returning

http://192.168.1.144:9988/dojo19Lib/projectName/appName/common/js/custom/controllers/categories.js 404 (Not Found) 
1
The Dojo Library Server should be checking your app's common directory for modules in addition to the dojolib project. Is your module under this directory? I used the Dojo Class wizard to create a module called controller under appName/common/js/custom. When I Preview the application, the request to the server is http://localhost:9988/dojo19Lib/projectName/appName/common/js/custom/controller.js, which ends up being resolved. - nsand
for some reason i had to put in packages: [ { name: 'js', location: location.pathname.replace(/\/[^/]+$/, '') + '/js' } ]" to make it work. i will take it out and try again - tik27
removed the package on my dojo.js and got the 404 error again::192.168.1.144:9988/dojo19Lib/projectName/appName/common/js/… 404 (Not Found) - tik27
You are using the AMD features with a non-standard directory layout, therefore you need to configure your loader so that it knows where to find the modules. That's why it works when you need to add the packages attribute to your dojoConfig. Details are explained here : dojotoolkit.org/reference-guide/1.9/loader/amd.html#the-amd-api - Philippe
@IdanAdar - Ended up using the dojo packages construct to have dojo reference my local js for my custom files. - tik27

1 Answers

0
votes

I had to add a package mapping to the js folder in djconfig. No 100 percent sure if you would still need this in the final build, because it seems that in final build the dojo directories get copied into common root directory.

 packages: [ 
     { name: 'js', 
      location: location.pathname.replace(/\/[^/]+$/, '') + '/js' 
     } ]"