gpt4 book ai didi

javascript - 在 YAML 中定义只有一个对象的数组

转载 作者:行者123 更新时间:2023-11-30 17:42:41 27 4
gpt4 key购买 nike

我正在尝试使用 load-grunt-config更好地组织我的 Grunt 任务。

到目前为止,我对此没有任何问题。现在,我试图配置类似 imagemin 的东西.

所以,基本上这是我试图在 YAML 中复制的结构:

dynamic: {                         // Another target
files: [{
expand: true, // Enable dynamic expansion
cwd: 'src/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'dist/' // Destination path prefix
}]
}

这是我的尝试:

images:
files: [
expand: true
cwd: '<%= ui %>/img/'
src:
- '**/*.{png,jpg,gif}'
dest: '<%= dist %>/img'
]

但是,一定是出了什么问题,因为插件无法获取正确的数据,因此失败了。

>> JS-YAML: missed comma between flow collection entries in "grunt/imagemin.yaml" at line 4, column 8:
>> cwd: '<%= ui %>/img/'
>>

有谁知道哪里出了问题?

最佳答案

方括号仅用于行内列表。您的文件列表应如下所示:

images:
files:
- expand: true
cwd: '<%= ui %>/img/'
src:
- '**/*.{png,jpg,gif}'
dest: '<%= dist %>/img'

您可以使用像 this 这样的在线解析器来测试 YAML 的语法是否正确。一个。

关于javascript - 在 YAML 中定义只有一个对象的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20740076/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com