2013-03-20 68 views
2

所以我使用yeoman init創建了一個項目,它使用requirejs,我希望用almondjs替換requirejs以使其加載速度更快。我怎樣才能做到這一點?如何用yeoman Gruntfile.js替換requirejs與almondjs?

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

確保你在使用Yeoman 1.0而不是早期版本。它使用具有杏仁支持的grunt-requirejs。 rjs在1.0之前的版本中使用。

請參閱https://github.com/asciidisco/grunt-requirejs/blob/master/docs/almondIntegration.md的文檔。看起來你可能需要做的就是將almond: true添加到Gruntfile中的requirejs選項(或者不取決於你想要做什麼 - 再次參閱文檔)。

+0

嗨,但我的Gruntfile中沒有requirejs,我的意思是 - yeoman生成一個Gruntfile.js,唯一需要提到的是: – Phil 2013-03-20 05:44:54

+0

rjs在1.0版之前的Yeoman中使用。從Yeoman 1.0開始,應該用grunt-requirejs替換。至少這是我的理解。 – Trott 2013-03-20 05:46:28

+0

我會盡力謝謝! – Phil 2013-03-20 05:47:24