requirejsbreezedurandalasp.net-spa

How to you reference a required script that is bundled?


I'm working with the Hot Towel SPA template and I'm trying to add in some data that I want to get from breeze. I have the breeze nuget package installed and the breeze script files are in the scripts folder of the site.

I can reference it by using the actual file name like the following:

define(['durandal/app', '../scripts/breeze.min.js'], function (app, breeze) {
...
});

However, this will break when my site is running in release mode and the script is actually bundled. Plus, it is really ugly and feels like a hack to put the full name in there.

What is the correct way to do this?


Solution

  • By default Durandal loads external libraries via normal script calls not via requirejs. Same is true for HotTowel.

    e.g. https://github.com/BlueSpire/Durandal/blob/master/index.html#L31

    or if your platform supports it via bundling

    https://github.com/johnpapa/PluralsightSpaJumpStartFinal/blob/master/SPAJumpStart/App_Start/BundleConfig.cs#L18

    Simply load breeze before requiring main.js and you should be good to go.