I'm facing some challenges while setting up r.js with require in my Angular application. As I am new to AMD, solving this issue might be a simple task for someone experienced. However, I need to maintain the current directory structure as it allows me to easily add more clients using the same Default components.
The error I encounter specifies that it is unable to locate the controller dependencies. It seems to be trying to reference them from Client#1/Directory_For_Prod_Packs/Angular/Default/_Controllers/.js. This results in the entire absolute path being added at the end of the build file location. Any assistance on this would be greatly appreciated. Ideally, I'd like to either have a single pack containing all directives, services, controllers, etc., or separate packs for controllers.js, directives.js, and other modules.
Here's an overview of my directory structure:
- Angular
- Lib
- angular.js
- Default
- Controllers
- _Controllers.js //pack of controllers
- .js //individual Controller files
- Directives
- _Directives.js
- .js
- Controllers
- Client#1
- main.js //require config
- app.js
- build.js // r.js build config
- Lib
Below is my build.js configuration for r.js:
({
baseUrl: '../../lib/Angular',
dir: "../../Client#1/ProductionBuild",
paths: {
"controllers": '../../Default/_Controllers/_Controllers',
},
modules: [
{
name: "controllers"
}
]
})
Finally, here is my _Controller.js code snippet:
define(['angular',
'../../Default/_Controllers/controller1.js',
'../../Default/_Controllers/controller2.js'],
function(angular) {
'use strict';
var dependencies = ['controller1',
'controller2',];
angular.module('app.controllers', dependencies);
}
);