angular-requirejs-seed
angular-requirejs-seed copied to clipboard
require.js question, may be issue
Hi. Am new to angular and stuff. Found this thing in search for a way to compile angular app for production in to a single file. Hoped to use require.js optimize http://requirejs.org/docs/optimization.html
From first try it did not work that well. I did install bower and dependencies trough it. Then installed require.js globally. Then created build.js file for optimizer
({
baseUrl: "app/js/",
paths: {
angular: '../../bower_components/angular/angular',
angularRoute: '../../bower_components/angular-route/angular-route',
angularMocks: '../../bower_components/angular-mocks/angular-mocks',
text: '../../bower_components/requirejs-text/text'
},
name: "main",
out: "main.min.js",
optimize: "none"
})
And changed require.js data-main to point to it.
From first look in to the file it seems to be fine, found dependencies and compiled everything together but it does not work. For example that's how it defined angular dependency.
define("angular", function(){});
As a result in
define('services',['angular'], function (angular) {
angular.module('myApp.services', [])
.value('version', '0.1');
});
angular is undefined.
Can may be someone point me to what I am doing wrong or if there is better way to have nicely separated angular.js files compiled for production?
I realize this is 6mo old but... just wanted to state for posterity sake that since Angular does not follow any standard module definitions, you have to use RequireJS Shims to use Angular as describe in the configuration for this project... Just have to look at https://github.com/tnajdek/angular-requirejs-seed/blob/master/app/js/main.js for the example config.