Grunt imagemin正在运行但没有缩小

时间:2015-10-07 15:31:13

标签: gruntjs grunt-contrib-imagemin

Image-min正常运行,但是为什么会缩小0张图像?

在我的终端上运行代码后:

    $ grunt imagemin
    Running "imagemin:dist" (imagemin) task
    Minified 0 images (saved 0 B)

Done, without errors.

我不明白,我尝试加载不同的图像,但仍然没有压缩。

imagemin part on my grunt:

//Image min ===============================

            var imagemin;
            config.imagemin = imagemin = {};
                imagemin.dist = {
                     options: {
                            optimizationLevel: 5,
                            progressive: true,
                          },
                    dynamic: {
                        files: [{
                            expand: true,
                            cwd: 'assets/images',
                            src: ['**/*.{png,jpg,gif}'],
                            dest: 'public/images'
                        }]
                    }

                };  

1 个答案:

答案 0 :(得分:2)

我的问题是:动态:{},不应该有,在他们的文档中他们只是解释了如何使用动态和静态,但不应该在代码中。它有点混乱,但无论如何我修好了。

没有动态{}的代码。

//Image min ===============================

            var imagemin;
            config.imagemin = imagemin = {};
                imagemin.dist = {
                     options: {
                            optimizationLevel: 5,
                            progressive: true,
                          },

                        files: [{
                            expand: true,
                            cwd: 'assets/images',
                            src: ['**/*.{png,jpg,gif}'],
                            dest: 'public/images'
                        }]

                };