nuxt-community / imagemin-module

Automatically optimize (compress) all images used in Nuxt.js
MIT License
50 stars 1 forks source link

Using webp still doesn't work #29

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi @mickaelchanrion Sorry for delay response

You can configure it like this:

export default {
  buildModules: [

    // gif,jpb,png,svg
    ['@nuxtjs/imagemin', {
      imageminOptions: {
        plugins: [
          ['gifsicle', { interlaced: true }],
          ['jpegtran', { progressive: true }],
          ['optipng', { optimizationLevel: 5 }],
          ['svgo', { plugins: [{ removeViewBox: false }] }]
        ]
      }
    }],

    // webp
    // https://www.npmjs.com/package/imagemin-webpack#name
    ['@nuxtjs/imagemin', {
      imageminOptions: {
        name: '[path][name].webp',
        plugins: [
          ['webp', { resize: { width: 1280, height: 800 } }]
        ]
      }
    }]
  ]
}

Originally posted by @ricardogobbosouza in https://github.com/nuxt-community/imagemin-module/issues/21#issuecomment-782689315

Hello. If you do everything as you wrote, then with the command "nuxt build" I get an error:

Nuxt Fatal Error
ValidationError: Invalid options object.
Image Minimizer Plugin has been initialized using an options object that does not match the API schema.
- options has an unknown property 'imageminOptions'. These properties are valid:
object { test?, include?, exclude?, minimizerOptions?, cache?, filter?, severityError?, loader?, maxConcurrency?, filename?, deleteOriginalAssets? }
ricardogobbosouza commented 3 years ago

Hi @veselllov Use minimizerOptions instead of imageminOptions