Reputation: 473
I have installed the Graphicmagik
and created the following Gruntfile.js
:
module.exports = function(grunt) {
grunt.initConfig({
responsive_images: {
dev: {
options: {
engine: 'gm',
sizes: [{width: 320, name: 'small'},
{width: 640, name: 'medium'},
{width: 800, name: 'large' }
]
}
},
/*
You don't need to change this part if you don't change
the directory structure.
*/
files: [{
expand: true,
src: ['**/*.jpg'],
cwd: 'images_src/',
dest: 'images/'
}]
},
/* Clear out the images directory if it exists */
clean: {
dev: {
src: ['images'],
},
},
/* Generate the images directory if it is missing */
mkdir: {
dev: {
options: {
create: ['images']
},
},
},
/* Copy the "fixed" images that don't go through processing into the images/directory */
copy: {
dev: {
files: [{
expand: true,
src: 'images_src/fixed/*.{gif,jpg,png}',
dest: 'images/'
}]
},
},
});
grunt.loadNpmTasks('grunt-responsive-images');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-mkdir');
grunt.registerTask('default', ['clean', 'mkdir', 'copy', 'responsive_images']);
};
Project folder tree:
project
css
images_src
fixed
node_modules
grunt-contrib-clean
grunt-contrib-copy
grunt-contrib-mkdir
grunt-responsive-images
"other grunt dependencies"
When I $grunt responsive_images
, I get the error following error:
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.
>> Unable to compile; no valid source files were found.
Running "responsive_images:files" (responsive_images) task
Fatal error: Unable to read configuration.
Have you specified a target? See: http://gruntjs.com/configuring-tasks
I changed the cwd and src several times but can't make it work! I get that the cwd ('current working directory') is the folder where the images are stored, the src is where I identify the file/file extention that I want to convert. So I think that this setup is correct. But why does it gives this error?
Upvotes: 1
Views: 166
Reputation: 2248
The files are defined outside of the responsive_images:dev
target. Move the files
block inside the dev
target to fix:
responsive_images: {
dev: {
options: {
engine: 'gm',
sizes: [{width: 320, name: 'small'},
{width: 640, name: 'medium'},
{width: 800, name: 'large' }
]
},
files: [{
expand: true,
src: ['**/*.jpg'],
cwd: 'images_src/',
dest: 'images/'
}],
},
},
Upvotes: 1