在 Assemble 创建文件后,我试图让 prettify 运行一个目录并将 html 文件美化到同一目录中。一起运行默认任务时,prettify 会抛出错误:
Running "prettify:indent" (prettify) task
Warning: Object 2 has no method 'indexOf' Use --force to continue
随后,当我单独运行每个任务时,一切正常:
$ grunt assemble; grunt prettify
这是我的 Gruntfile:
site: grunt.file.readYAML('src/template/data/site.yml'),
assemble: {
options: {
prettify: {indent: 2},
marked: {sanitize: false},
data: "src/template/data/site.yml",
layoutdir: 'src/template/layouts',
},
all: {
options: {production: false,layout: 'default.hbs'},
files: [
{ expand: true, cwd: 'src/template/pages', src: ['**/*.hbs'], dest: 'dist/' }
]
}
},
prettify: {
options: {
indent: 4,
wrap_line_length: 78,
brace_style: 'expand',
},
all: {
expand: true,
cwd: 'dist/',
ext: '.html',
src: ['*.html'],
dest: 'dist/'
}
}
有人可以指出我正确的方向吗?可以美化输出到相同的源目录吗?