Home

Issue: 2627

On minifying images

[issue link]

I have difficulties in minifying images. I read the docs about extending the Webpack configuration. However, this code does not do anything to my assets.

const imageminloader = require('imagemin-webpack').imageminloader

module.exports = {
  ...
  build: {
    extend (config, ctx) {
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          test: /\.(png|jpe?g|gif|svg)$/,
          use: [{
            loader: 'url-loader',
            query: {
              limit: 1000, // 1kB
              name: 'img/[name].[hash:7].[ext]'
            }
          }, {
            loader: 'imageminloader'
          }]
        })
      }
    }
  }
  ...
}

After running nuxt generate, the output does not produce any error and my assets remain untouched. Is there anything I misunderstand?

I also searched for a property in the generate.minify object without success.

As for static files, I suppose they are completely unplugged from Webpack and there is no way to minify images with Nuxt.

Thank you for your help.

This question is available on Nuxt.js community (#c2286)