我在为 grunt-contrib-imagemin 任务构建 travis-ci 期间遇到错误...
Warning: Running "imagemin:dist" (imagemin) task
Fatal error: Cannot read property 'contents' of undefined
grunt build 在我的本地机器上成功运行,但是通过 travis-ci 执行时失败
Gruntfile.js
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
本地 Grunt 构建(输出)
Running "imagemin:dist" (imagemin) task
Minified 9 images (saved 77.32 kB)
Done, without errors.
Execution Time (2016-01-13 17:04:49 UTC)
imagemin:dist 1.6s 100%
Total 1.6s
Travis CI grunt 构建(输出)
Warning: Running "imagemin:dist" (imagemin) task
Fatal error: Cannot read property 'contents' of undefined
Execution Time (2016-01-13 17:00:32 UTC)
loading tasks 9ms 2%
imagemin:dist 441ms 98%
Total 450ms Use --force to continue.
Aborted due to warnings.
我试图确定我在任务中声明 src 的方式是否存在语法问题……但是,情况似乎并非如此……因为我可以使用几种不同的方法成功地在本地完成构建而不会出错语法样式,包括 Grunt 为 grunt-contrib-imagemin 提供的示例
参考:https ://github.com/gruntjs/grunt-contrib-imagemin
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
}]
有什么想法或建议吗?