tier1 tier1 - 4 months ago 34
AngularJS Question

Grunt build does not seem to be including ui-router

I've tried this a few different ways now but I've installed angular-ui-router with bower using the following command:


bower install angular-ui-router


Awesome, so I can see that there is an angular-ui-router folder in my bower_components directory. I can also see it listed as a dependency in bower.json

I included the path in my project like so

<script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>


Running grunt serve, everything works perfectly. All of my bower components load and ui-router is routing.

Running grunt build, the build succeeds. But hosting the site, it seems that ui-router was not included. I get this all too familiar error


Module 'ui.router' is not available!


After poking around with grunt configs and a few other things, my last ditch effort was to stick a CDN script tag in my project

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js"></script>


However, I get the same errors as above after running grunt build.

Is there some special trick to including ui-router? All other bower components seem to be included just fine.

Answer

Ok, I just saw that ui-router doesnt have the 'main' entry in package.json. I didnt have time to poke more. But, in bower.json file. You can add overrides entry so that it adds the file in packaging dependency.

"overrides": {
  "angular-ui-router": {
    "main": [
      "release/angular-ui-router.js"
    ]
  }
}

I'm not too sure, about the path. You can check your angular-ui folder to be sure. Also, dont point to the minified file, as uglify will run minification on your files.