我正在尝试设置grunt,我已经下载了GraphickMagick和ImageMAgick。 我的操作系统是LINUX MINT。 当我尝试运行$ grunt时,我收到以下错误:
-Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*
我当前的目录是 / project-server :
Running "responsive_images:dev" (responsive_images) task
Unable to compile; no valid source files were found.
Unable to compile; no valid source files were found.
Gruntfile.js
project-server/images/
project-server/img/
project-server/node_modules/
project-server/Gruntfile.js
project-server/package.json
的package.json
module.exports = function(grunt) {
grunt.initConfig({
responsive_images: {
dev: {
options: {
engine: 'im',
sizes: [{
name: 'small',
width: '30%',
suffix: '_small',
quality: 20
},{
name: 'large',
width: '50%',
suffix: '_large',
quality: 40
}]
},
files: [{
expand: true,
src: ['*.{gif,jpg,png}'],
cwd: 'images/',
dest: 'images/'
}]
}
},
});
grunt.loadNpmTasks('grunt-responsive-images');
grunt.registerTask('default', ['responsive_images']);
};
答案 0 :(得分:0)
所以,
src: ['*.{gif,jpg,png}'],
cwd: 'images/',
dest: 'images/'
注意 cwd 值,它表示我当前的目录是/ images,所以每当他试图找到 src 的值时,它都会在/ images下搜索。但我的文件{.png,.jpeg}不在/ images下。
然后,我所要做的就是评论 cwd 值。它工作得很好!