Skip to content

Instantly share code, notes, and snippets.

@bmelton
Created February 24, 2017 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmelton/e50abee6e4808ff4e5177f23cd9db9c3 to your computer and use it in GitHub Desktop.
Save bmelton/e50abee6e4808ff4e5177f23cd9db9c3 to your computer and use it in GitHub Desktop.
Working Gruntfile
/*
After you have changed the settings at "Your code goes here",
run this with one of these options:
"grunt" alone creates a new, completed images directory
"grunt clean" removes the images directory
"grunt responsive_images" re-processes images without removing the old ones
*/
module.exports = function(grunt) {
grunt.initConfig({
responsive_images: {
dev: {
options: {
engine: 'im',
sizes: [{
width: "800px",
suffix: "_shrunk",
quality: "high"
}]
},
/*
You don't need to change this part if you don't change
the directory structure.
*/
files: [{
expand: true,
src: ['*.{gif,jpg,png}'],
cwd: 'images_src/',
dest: 'images/'
}]
}
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'images_src/',
src: ['**/*.{png,jpg,gif}'],
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.loadNpmTasks('grunt-contrib-imagemin'); //mine
grunt.registerTask('default', ['clean', 'mkdir', 'copy', 'imagemin']); //added " , 'imagemin'"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment