Grunt watch does not detect new images

1

Hello, I'm trying to get the grunt to watch in a directory and when a new image is added, it compares it. However, it does not perform anything when I add images to the directory, it works perfectly for my less and js.

package.json

"devDependencies": {
    "grunt": "^1.0.1",
    "grunt-cli": "^1.2.0",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-cssmin": "^2.2.1",
    "grunt-contrib-imagemin": "^2.0.1",
    "grunt-contrib-less": "^1.4.1",
    "grunt-contrib-uglify": "^3.0.1",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-newer": "^1.3.0"
  },

gruntfile.js

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    imagemin: {
        dynamic: {
            options: {
                optimizationLevel: 3,
                svgoPlugins: [{removeViewBox: false}]
            },
            files: [{
                expand: true,
                cwd: 'src/img/',
                src: '*.{png,jpg,jpeg,gif,svg}',
                dest: 'dist/img'
            }]
        }
    },

    watch: {
        img: {
            files: 'src/img/*.{png,jpg,jpeg,gif,svg}',
            tasks: 'dist-img-newer'
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-newer');

grunt.registerTask('dist-img-newer', ['newer:imagemin']);
    
asked by anonymous 31.08.2017 / 01:22

0 answers