Reputation: 2504
Here is my grunt file part where I define the requirejs task:
requirejs: {
dist: {
options: {
name: 'almond',
mainConfigFile: "<%= yeoman.app %>/js/main.js",
out: '.tmp/require/js/app.js',
insertRequire: ['startup'],
optimize: 'none'
}
}
}
Now in my andular application I mainly load vendor sources that I downloaded through bower.
However I have this need to load the amplitude.com module and it does not seem to have a bower link.
So here is my code:
define(['application/amplitude/module', 'require'], function (module, require) {
'use strict';
module.provider('$amplitude', [function $amplitudeProvider() {
this.$get = ['$q', function ($q) {
var sync = $q.defer();
requirejs.config({
paths: {
'amplitude': 'https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.4.1-min.gz'
},
shim: {
'amplitude': {
exports: 'amplitude'
}
}
});
require(['amplitude'], function (amplitude) {
sync.resolve(amplitude);
});
return {
getInstance: function() { return sync.promise; }
};
}];
}]);
});
It works like a charm in dev mode. Now when I try to grunt release (which runs the almond task) the thats succeeds but I get an error at runtime saying
Uncaught Error: undefined missing
I tried different ways of writing that but all failed... Anyone able to show the light?
Upvotes: 1
Views: 23