【发布时间】:2016-06-15 00:19:24
【问题描述】:
在我的设置中,我使用grunt-load-config 将我的 gruntfile 拆分为单独的文件。 这意味着我要使用的每个 grunt 插件都有一个文件。
我的gruntfile.js 看起来像这样:
module.exports = function(grunt) {
var path = require('path');
// measures the time each task takes
require('time-grunt')(grunt);
// load grunt config
require('load-grunt-config')(grunt, {
jitGrunt: true,
configPath: path.join(process.cwd(), 'Interface/grunttasks')
});
};
我在Interface/grunttasks/assemble.js 中的组装设置看起来像这样
module.exports = {
options: {
flatten: true,
partials: ['<%= package.html %>/_partials/*.html'],
layout: '<%= package.html %>/_layouts/main.html'
},
pages: {
src: ['<%= package.pages %>/**/*.html',
dest: '<%= package.prototype %>'
}
};
这完全符合预期,但现在我想使用一组组装助手。但我不确定我应该如何将它们添加到我的 grunt 设置中,以便组装(以及车把)可以使用它们。
我查看了 prettify 帮助程序,他们的安装说明只是“将以下内容添加到您的应用程序”
var helpers = require('prettify');
然后我应该能够将配置添加到我的 gruntfile 中的 assemble 块中,就像这样
grunt.initConfig({
assemble: {
options: {
prettify: {
mode: 'js', // 'html' is defined by default
condense: true,
padcomments: true,
indent: 4
}
},
...
}
});
但我似乎无法正确注册插件。我猜是因为我已经拆分了我的 grunt 文件?
谁能解释如何在这个 grunt 设置中添加组装插件/帮助程序?
【问题讨论】: