gruntjs / grunt-contrib-imagemin

Minify PNG, JPG, GIF and SVG images.
https://gruntjs.com
MIT License
1.21k stars 175 forks source link

imagemin is not defined #398

Closed RajaRakoto closed 2 years ago

RajaRakoto commented 2 years ago

Hi, can you help me to solve this error 'imagemin is not defined', I am using 'grunt-contrib-imagemin' v4.0.0, I am trying to minify my images (svg, png) but when I type the grunt command, the console returns me this:

>> ReferenceError: imagemin is not defined

Here are my configuration about imagemin:

grunt.initConfig({
imagemin: {
            static: {
                options: {
                    optimizationLevel: 1, // between 0 ~ 7
                    use: [
                        imagemin.optipng(),
                        imagemin.gifsicle(),
                        imagemin.jpegtran(),
                        imagemin.svgo(),
                    ],
                },
                files: [
                    {
                        './src/dist/images/test-min.png': './src/assets/images/test.png',
                    },
                ],
            },
            dynamic: {
                files: [
                    {
                        expand: true,
                        cwd: './src/assets/images/',
                        src: ['**/*.{png,jpg,gif}'],
                        dest: './src/dist/images/',
                    },
                ],
            },
        },
        )}
grunt.registerTask('default', ['imagemin']);

P.S: I want to clarify that I use 'load-grunt-tasks' to load my grunt plugins