如何用一个简单的Gruntfile.js代替almondjs的需求



所以我使用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'
},

确保您使用的是Yeoman 1.0而不是更早的版本。它使用了grunt- requirels,它有杏仁支持。RJS在1.0之前的版本中使用。

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

最新更新