2

所以我使用 yeoman init 创建了一个项目,它使用了 requirejs,我希望用 almondjs 替换 requirejs 以使其加载更快。我怎样才能做到这一点?

AlmondJS 在这里:https ://github.com/jrburke/almond

RequireJS 在这里:http ://requirejs.org/

约曼:http: //yeoman.io/


在 Gruntfile.js 中唯一提到 require.js 是:

// rjs configuration. You don't necessarily need to specify the typical
// `path` configuration, the rjs task will parse these values from your
// main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
//
// name / out / mainConfig file should be used. You can let it blank if
// you're using usemin-handler to parse rjs config from markup (default
// setup)
rjs: {
  // no minification, is done by the min task
  optimize: 'none',
  baseUrl: './scripts',
  wrap: true,
  name: 'main'
},
4

1 回答 1

4

确保您使用的是 Yeoman 1.0 而不是早期版本。它使用支持杏仁的 grunt-requirejs。rjs 用于 1.0 之前的版本。

请参阅https://github.com/asciidisco/grunt-requirejs/blob/master/docs/almondIntegration.md上的文档。看来您可能需要做的就是almond: true在 Gruntfile 中添加 requirejs 的选项(或者不取决于您想要做什么——再次参见文档)。

于 2013-03-20T05:34:59.837 回答