Skip to content

Instantly share code, notes, and snippets.

@levyadams
Created June 2, 2018 18:22
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 levyadams/96f1fd3ed6d58236305832f378352be3 to your computer and use it in GitHub Desktop.
Save levyadams/96f1fd3ed6d58236305832f378352be3 to your computer and use it in GitHub Desktop.
/*
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: {
sizes: [
{width:1600, suffix: '_large_1x', quality:60},
{width:800, suffix: '_medium_1x', quality:70},
{width:550, suffix: '_small_1x', quality:100}
]
},
/*
You don't need to change this part if you don't change
the directory structure.
*/
files: [{
expand: true,
src: ['*.{gif,jpg,png}'],
cwd: 'img',
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 any images we don't want to resize */
copy: {dev: {files: [{expand: true, src: 'imgs/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','responsive_images']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment