我已经把这个问题回复到原来的形式,这样以后的读者就能读得更清楚了。
在我的Gruntfile.js中我有一些繁重的组装任务。
assemble: {
options: {
flatten: true,
layoutdir: 'test-templates/meta_test_templates',
partials: [
'test-templates/general_includes/**/*.hbs',
'test-templates/users/**/*.hbs',
'test-templates/content/**/*.hbs']
},
webmaster_crud: {
options: { layout: 'webmaster_crud.hbs' },
dest: '../compiled-tests/content/webmaster/',
src: ['test-templates/content/content_types/*.hbs']
}
}我想在每个输出文件的前缀加上单词webmaster
因此,产出如下:
/compiled-tests/content/webmaster/webmaster_file1.html
/compiled-tests/content/webmaster/webmaster_file2.html
etc安装在我的package.json文件中的软件包
"devDependencies": {
"assemble": "^0.7.3",
"grunt": "^0.4.5",
"grunt-assemble": "^0.4.0",
"grunt-contrib-clean": "^0.7.0"
}更新19/1/16我已经包含了传递给我的grunt.initConfig的整个汇编语言对象,我还在package.json中包含了依赖项。
更新12/1/16未注释的expand命令并包含随后的错误消息
更新12/1/16已经将问题返回到它的原始形式,没有我在函数中不包括path变量时发现的附加错误。
发布于 2016-01-19 03:18:10
我并不完全清楚你想要什么,但是我认为你可能会寻找的是Grunt的“重命名”选项。下面的配置可能会产生您希望的结果:
var path = require('path');
webmaster_crud: {
options: {
layout: 'webmaster_crud.hbs'
},
expand: true,
flatten: true,
rename: function (dest, matchedSrcPath) {
var filename = 'webmaster_' + path.basename(matchedSrcPath);
return path.join(dest, path.dirname(matchedSrcPath), filename);
},
dest: './compiled-tests/content/webmaster/',
src: ['test-templates/content/content_types/*.hbs']
}https://stackoverflow.com/questions/34861054
复制相似问题