2

我有一个需要 Facebook SDK 的模块。我想知道我应该如何配置 SDK 的加载,以便 RequireJS 优化器正确处理它。

在应用程序中:

require.config({
  paths: {
      'facebook' : '//connect.facebook.net/en_US/all'
  }
});

在构建配置文件中:

{
  ...
  paths: {
     'facebook' : 'empty:'
  }
}

据我了解,上面的代码强制优化器跳过该脚本的优化。问题是,优化后SDK不再加载。

4

1 回答 1

4

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

于 2012-11-13T21:08:29.960 回答