分割Gruntfile [英] Split up Gruntfile
问题描述
我想要这样的事情:
Gruntfile.js
module.exports = function(grunt){
grunt.initConfig({ b $ b concat:getConcatConfiguration()
});
}
functions.js
function getConcatConfiguration(){
//做一些事情来生成并返回配置
}
如何将functions.js加载到我的Gruntfile.js?
< )! 我建议将所有每个特定于任务的配置都放到一个以配置命名的文件中(在这种情况下,我将它命名为 此外,我将 Gruntfile.js grunt / concat.js 您应该如何操作: 已经有人创建了一个名为 load-grunt-config 。这正是你想要的。 继续前进,并将所有内容(如上所述)放在单独的文件中放入您选择的位置(默认文件夹ist 那么你的标准gruntfile应该看起来像这样: My Gruntfile is becoming pretty big right now and I want to split it up into multiple files. I've Googled and experimented a lot but I can't get it to work. I want something like this: Gruntfile.js functions.js How can I load functions.js into my Gruntfile.js? How you can do it: you need to export your concat configuration, and require it in your Gruntfile (basic node.js stuff)! i would recommend putting all every taskspecific configuration into one file named after the configuration (in this case i named it Moreover i moved Gruntfile.js grunt/concat.js
How you SHOULD do it: there was already someone there who created a module named load-grunt-config. this does exactly what you want. go ahead and put everything (as mentioned above) into separate files into a location of your choice (default folder ist then your standard gruntfile should probably look like this:
这篇关于分割Gruntfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
concat.js < code $)。
concat.js
移至名为 grunt
module.exports = function(grunt){
grunt.initConfig({
concat:require('grunt / concat')(grunt);
});
};
module.exports = function getConcatConfiguration(grunt){
//做一些东西来生成并返回配置
};
咕噜
)。
module .exports = function(grunt){
require('load-grunt-config')(grunt);
//在这里定义一些别名任务
};
module.exports = function(grunt) {
grunt.initConfig({
concat: getConcatConfiguration()
});
}
function getConcatConfiguration() {
// Do some stuff to generate and return configuration
}
concat.js
).concat.js
into a folder named grunt
module.exports = function(grunt) {
grunt.initConfig({
concat: require('grunt/concat')(grunt);
});
};
module.exports = function getConcatConfiguration(grunt) {
// Do some stuff to generate and return configuration
};
grunt
). module.exports = function(grunt) {
require('load-grunt-config')(grunt);
// define some alias tasks here
};