Optimizing and loading external dependencies with requirejs

送分小仙女□ 提交于 2019-12-11 02:28:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!