我的split文件现在变得相当大,我想把它分成多个文件。我在谷歌上搜索并做了很多实验,但我无法让它发挥作用。
我想要这样的东西:
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
concat: getConcatConfiguration()
});
}functions.js
function getConcatConfiguration() {
// Do some stuff to generate and return configuration
}如何将functions.js加载到Gruntfile.js中?
发布于 2014-12-08 13:34:45
你能做什么:
您需要导出您的concat配置,并在您的Gruntfile中要求它(基本的node.js配置)!
我建议将所有特定于任务的配置放在一个以配置命名的文件中(在本例中,我将其命名为concat.js)。
此外,我将concat.js移动到一个名为grunt的文件夹中。
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
concat: require('grunt/concat')(grunt);
});
};grunt/conat.js
module.exports = function getConcatConfiguration(grunt) {
// Do some stuff to generate and return configuration
};您应该如何做:
已经有人创建了一个名为负载-增益-配置的模块。这正是你想要的。
继续将所有内容(如上面提到的)放入您选择的位置(默认文件夹ist grunt)中。
那么您的标准gruntfile应该如下所示:
module.exports = function(grunt) {
require('load-grunt-config')(grunt);
// define some alias tasks here
};https://stackoverflow.com/questions/27356538
复制相似问题