问题
I have a module that requires the Facebook SDK. I'm wondering how I should configure loading of the SDK so that it's handled properly by the RequireJS optimizer.
In app:
require.config({
paths: {
'facebook' : '//connect.facebook.net/en_US/all'
}
});
In build profile:
{
...
paths: {
'facebook' : 'empty:'
}
}
As far as I understand it, the code above forces the optimizer to skip optimization of that script. The problem is, the SDK is no longer loaded after optimization.
回答1:
As part of the build process I was using Almond as the AMD loader rather than RequireJS. It appears Almond (0.2.0) does not support loading external dependencies this way. I dropped Almond and switched back to bundling RequireJS during optimization and it worked.
http://requirejs.org/docs/optimization.html#onejs
来源:https://stackoverflow.com/questions/13366103/optimizing-and-loading-external-dependencies-with-requirejs