Durandal optimization using weyland doesn't work with requirejs paths

418 views Asked by At

I've developed a SPA website using great HotTowel template by John Papa. While doing optimizations I've confront a problem. I've simplified the situation to make the question more clear.

There's some place that I use require to get a JavaScript viewModel like:

require(["myScripts/serviceRunner"], function (viewModel) {
    console.log("ViewModel loaded:" + viewModel)                            
                  });

At the server side, there's a controller and action which handles the http requests like:

http://localhost:1441/api/UL/LoadJS

So instead of having require(["http://localhost:1441/api/UL/LoadJS/serviceRunner"]. I've defined a path like:

require.config({
    paths: {
    "myScripts": "http://localhost:1441/api/UL/LoadJS"
    ...

Everything works just fine. But after optimization and creating main-built using weyland, The require cannot load the given path.

Is there any configuration that I missed for optimization?

FYI, I'm using Durandal 2.0.1

1

There are 1 answers

1
Krzysztof Cieslak On

Have You add "myScripts" entry in weyland-config.js file?

As far as I am concerned You have to add same paths You do define in main.js also in weyland-config.js in rjs paths part.

exports.config = function(weyland) {
...
   .task.rjs({
   ...
      rjs:{
      ...
      paths : { 
           "myScripts": "http://localhost:1441/api/UL/LoadJS"
           ...
           }
      }
   });
}