I am a new Grunt user. I currently have a static_src/img
folder that contains the source image files (.psd) and image files (.png, .jpg, etc.). This folder is not public. Instead, I want to synchronize the change of only image files to another static/img
shared folder.
The problem is that it works well when I add / modify the image file in static_src/img
, but I don't know how to synchronize the change when deleting the file. Grunt-contrib-watch can detect deletion in static_src/img
, but I don't know how to delete a file in static/img
. I tried grunt-contrib-clean, but it doesn't seem to work for me, maybe I used it incorrectly.
My Gruntfile.js:
module.exports = function(grunt){ grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), copy: { dev: { files: [ {expand: true, cwd: 'static_src/img/', src:['**/*.{png,jpg,gif}'], dest: 'static/img/'} ] } }, clean: { dev: { src: ['static_src/img/**/*.png'] } }, watch: { copy: { files: ['static_src/img/**/*.{png,jpg,gif}'], tasks: ['copy'], options: { event: ['added', 'changed'], } }, remove: { files: ['static_src/img/**/*.{png,jpg,gif}'], tasks: ['clean'], options: { event: ['deleted'] } } } }); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-watch'); };
So how to delete a specific file in the grunt-contrib-watch task? Thank you for your help!
source share