Created
February 24, 2017 18:49
-
-
Save bmelton/e50abee6e4808ff4e5177f23cd9db9c3 to your computer and use it in GitHub Desktop.
Working Gruntfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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