1

Image-min 运行正常,但我得到 0 张图片缩小了,为什么?

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

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

Done, without errors.

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

imagemin 部分在我的咕噜声中:

//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'
                        }]
                    }

                };  
4

1 回答 1

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'
                        }]

                };  
于 2015-10-09T14:48:01.157 回答